Skip to main content
POST
/
langchain
/
cohere
/
v2
/
chat
Chat with model (LangChain - Cohere format)
curl --request POST \
  --url http://localhost:8080/langchain/cohere/v2/chat \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "command-r-plus",
  "messages": [
    {
      "role": "system",
      "content": "<string>",
      "tool_calls": [
        {
          "id": "<string>",
          "type": "function",
          "function": {
            "name": "<string>",
            "arguments": "<string>"
          }
        }
      ],
      "tool_call_id": "<string>",
      "tool_plan": "<string>"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "<string>",
        "description": "<string>",
        "parameters": {}
      }
    }
  ],
  "tool_choice": "AUTO",
  "temperature": 0.5,
  "p": 123,
  "k": 123,
  "max_tokens": 123,
  "stop_sequences": [
    "<string>"
  ],
  "frequency_penalty": 123,
  "presence_penalty": 123,
  "stream": true,
  "safety_mode": "CONTEXTUAL",
  "log_probs": true,
  "strict_tool_choice": true,
  "thinking": {
    "type": "enabled",
    "token_budget": 2
  },
  "response_format": {
    "type": "text",
    "schema": {}
  }
}
'
{
  "id": "<string>",
  "finish_reason": "COMPLETE",
  "message": {
    "role": "<string>",
    "content": [
      {
        "type": "text",
        "text": "<string>",
        "image_url": {
          "url": "<string>"
        },
        "thinking": "<string>",
        "document": {
          "data": {},
          "id": "<string>"
        }
      }
    ],
    "tool_calls": [
      {
        "id": "<string>",
        "type": "function",
        "function": {
          "name": "<string>",
          "arguments": "<string>"
        }
      }
    ],
    "tool_plan": "<string>"
  },
  "usage": {
    "billed_units": {
      "input_tokens": 123,
      "output_tokens": 123,
      "search_units": 123,
      "classifications": 123
    },
    "tokens": {
      "input_tokens": 123,
      "output_tokens": 123
    },
    "cached_tokens": 123
  },
  "logprobs": [
    {
      "token_ids": [
        123
      ],
      "text": "<string>",
      "logprobs": [
        123
      ]
    }
  ]
}

Body

application/json
model
string
required

Model to use for chat completion

Example:

"command-r-plus"

messages
object[]
required

Array of message objects

tools
object[]
tool_choice
enum<string>

Tool choice mode - AUTO lets the model decide, NONE disables tools, REQUIRED forces tool use

Available options:
AUTO,
NONE,
REQUIRED
temperature
number
Required range: 0 <= x <= 1
p
number

Top-p sampling

k
integer

Top-k sampling

max_tokens
integer
stop_sequences
string[]
frequency_penalty
number
presence_penalty
number
stream
boolean
safety_mode
enum<string>
Available options:
CONTEXTUAL,
STRICT,
NONE
log_probs
boolean
strict_tool_choice
boolean
thinking
object
response_format
object

Response

Successful response

id
string
finish_reason
enum<string>
Available options:
COMPLETE,
STOP_SEQUENCE,
MAX_TOKENS,
TOOL_CALL,
ERROR,
TIMEOUT
message
object
usage
object
logprobs
object[]

Log probabilities (if requested)