cheapaimodel

Create a message

Copiar
POST/v1/messages

Generate a message with the Anthropic Messages format. Authenticate with x-api-key or Authorization: Bearer. Only models whose catalog entry lists /v1/messages are supported here.

Authorization

x-api-key<token>

Your API key, Anthropic style. Accepted by /v1/messages.

In: header

Header Parameters

anthropic-version?string

Anthropic API version. Sent by the Anthropic SDKs automatically.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

model*string

A model ID from List models.

max_tokens*integer
Range1 <= value
messages*array<>
system?string|array<>
stream?boolean
Defaultfalse
temperature?number
Range0 <= value <= 1
top_p?number
top_k?integer
stop_sequences?array<string>
tools?array<>
tool_choice?
thinking?

Extended thinking, on models that support it.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

Copiar
curl -X POST "https://example.com/v1/messages" \  -H "Content-Type: application/json" \  -d '{    "model": "<model-id>",    "max_tokens": 1024,    "messages": [      {        "role": "user",        "content": "Hello!"      }    ]  }'
{  "id": "string",  "type": "message",  "role": "assistant",  "model": "string",  "content": [    {}  ],  "stop_reason": "string",  "usage": {    "input_tokens": 0,    "output_tokens": 0  }}