BazaarLinkBazaarLink
Sign in
DocsAPI ReferenceSDK ReferenceAgentic UsageAI Skills
Messages (Anthropic)

Create a message

Requests a model response using Anthropic's native /v1/messages shape; BazaarLink routes it to any supported model, not just Anthropic's own. Point the official Anthropic SDK's base_url at BazaarLink and existing code works unchanged. Accepts either Authorization: Bearer or the Anthropic SDK's conventional x-api-key header. If the resolved model isn't native Anthropic, BazaarLink transparently translates the request/response, preserving tool_use blocks and stop_reason semantics where possible.

POST/v1/messages

Authorizations

Authorizationrequired
string · header

API key as bearer token in the Authorization header.

Body

modelrequired
string

The model to use, provider-qualified, e.g. "anthropic/claude-sonnet-4.6".

minLength: 1
Example: "anthropic/claude-sonnet-4.6"
messagesrequired
Message[]

Array of conversation messages, at least one. Each has a role (user/assistant) and content (a string, or an array of content blocks such as text/image/tool_use/tool_result).

minLength: 1
max_tokensrequired
integer

Maximum number of tokens the response may generate. Unlike the OpenAI-compatible endpoints, this field is required in the Anthropic shape.

positive integer
Example: 1024
system
string | ContentBlock[]

System prompt — a separate top-level field, not a message inside the messages array (one of the main shape differences from the OpenAI format).

stream
boolean

true streams the response as SSE (message_start / content_block_delta / message_delta / message_stop events); omitted or false returns a single JSON response.

temperature
number

Sampling temperature — higher is more random, lower is more deterministic. Sampling values are forwarded without range validation; the model may clamp or ignore values outside its supported range. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

top_p
number

Nucleus sampling threshold. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

top_k
integer

Limits sampling to the K highest-probability tokens. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

stop_sequences
string[]

Array of strings where generation stops. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

tools
Tool[]

List of tool definitions the model may call, Anthropic-shaped (name, description, input_schema). Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

tool_choice
object

Controls whether/how the model is forced to call a tool, e.g. {type:"auto"}, {type:"any"}, {type:"tool", name:"..."}. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

thinking
object

Extended-thinking control object, e.g. {type:"enabled", budget_tokens:2048}. Only meaningful on reasoning models. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

metadata
object

Request metadata, e.g. {user_id:"..."}. Used for monitoring and abuse detection; has no effect on billing. Not validated by BazaarLink — forwarded as-is to the upstream. If the resolved model isn't native Anthropic, how this field is handled depends on BazaarLink's translation layer.

POST /v1/messages
curl https://api.bazaarlink.ai/v1/messages \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4.6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
Response examples

BazaarLink returns a standardized response and removes upstream-specific fields. usage.cost is the USD amount charged to the customer for this request. Use the opaque BazaarLink request id from the response id or x-request-id with GET /v1/generation; non-streaming responses also return it in x-generation-id. Stats may take a few seconds after completion; retry a 404 briefly. usage.cost and usage.bz_cost contain the same USD customer charge. Long non-streaming Chat, Messages, and Responses requests (about 12 seconds or longer) may start with whitespace keep-alive padding before the JSON body. Standard JSON parsers accept leading whitespace.

{
  "id": "85e6f35c71a31f19-SJC",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-4.6",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 10,
    "output_tokens": 12,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cost": 0.000186,
    "bz_cost": 0.000186
  }
}
Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
Create a message — BazaarLink API