Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tokmodel.com/llms.txt

Use this file to discover all available pages before exploring further.

The /v1/messages endpoint is compatible with the Anthropic Messages API format, making it easy to migrate workloads from Anthropic’s SDK or to use libraries that target Anthropic directly. You authenticate using your TokModel API key — you do not need an Anthropic API key. Route your Anthropic SDK to https://tokmodel.com and use your TokModel key to start using any model available on TokModel through the familiar Anthropic message format.

Request parameters

model
string
required
The ID of the model to use. You can use Anthropic model IDs (for example, anthropic/claude-opus-4-5) as well as any other model available on TokModel.
messages
array
required
An array of message objects representing the conversation. Each object requires a role ("user" or "assistant") and a content field (a string or array of content blocks).
max_tokens
integer
required
The maximum number of tokens to generate. This parameter is required by the Anthropic format.
system
string
A system prompt that sets the context and instructions for the model. Equivalent to a system role message in other formats.
temperature
number
default:"1"
Sampling temperature between 0 and 1. Lower values produce more consistent output.
stream
boolean
default:"false"
When true, streams the response as server-sent events in Anthropic’s streaming format.
top_p
number
Nucleus sampling threshold. Limits token selection to the smallest set whose cumulative probability exceeds top_p.
stop_sequences
string[]
An array of strings that cause the model to stop generating when encountered.

Response fields

id
string
A unique identifier for the message, prefixed with msg_.
type
string
Always "message".
role
string
Always "assistant" for generated responses.
content
array
An array of content blocks in the response. Each block has a type field (typically "text") and a text field with the generated content.
stop_reason
string
The reason generation stopped. One of "end_turn" (natural end), "max_tokens" (token limit reached), or "stop_sequence" (a stop sequence was matched).
model
string
The model that generated the response.
usage
object
Token counts for the request.

Example

Authenticate with your TokModel API key. You do not need an Anthropic API key to use this endpoint.

Request

curl https://tokmodel.com/v1/messages \
  --request POST \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "anthropic/claude-opus-4-5",
    "system": "You are a concise technical writer.",
    "messages": [
      { "role": "user", "content": "What is a vector database?" }
    ],
    "max_tokens": 256,
    "temperature": 0.5
  }'

Response

{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "A vector database stores and indexes high-dimensional numerical vectors, enabling fast similarity search. It is commonly used to power semantic search, recommendation systems, and retrieval-augmented generation (RAG) by finding the vectors closest to a given query vector."
    }
  ],
  "stop_reason": "end_turn",
  "model": "anthropic/claude-opus-4-5",
  "usage": {
    "input_tokens": 22,
    "output_tokens": 51
  }
}