TheaimartAIx DOCS
Home Get API key

Messages

POST /v1/messages

Use the Messages surface when an agent or SDK expects the Anthropic request, response and streaming event shapes. The same AIx key, wallet, routing controls and metering apply.

Note

For OpenAI-compatible clients, use /v1/chat/completions. Choose one surface per client; both reach the same AIx model catalog.

Request body

FieldTypeRequiredDescription
model string required Canonical AIx model id, or a supported Claude-style model alias.
messages array required Conversation turns with user or assistant roles. Content may be a string or an array of text, image, tool-use and tool-result blocks.
system string | array optional System instruction as plain text or an array of text blocks.
max_tokens integer default: 256 Maximum output tokens.
temperature number default: 0.7 Sampling temperature.
top_p number default: 1.0 Nucleus sampling.
stop_sequences array optional Custom stop sequences.
stream boolean default: false Return Anthropic-style server-sent events.
tools array optional Tool definitions using name, description and input_schema.
tool_choice object optional auto, any, none or one named tool.

Example

curl https://api.aix.theaimart.co/v1/messages \
  -H "Authorization: Bearer $AIX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [{"role":"user","content":"Explain this API in one sentence."}]
  }'
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["AIX_KEY"],
    base_url="https://api.aix.theaimart.co",
)

message = client.messages.create(
    model="anthropic/claude-sonnet-4-6",
    max_tokens=512,
    messages=[{"role": "user", "content": "Explain this API in one sentence."}],
)
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.AIX_KEY,
  baseURL: "https://api.aix.theaimart.co",
});

const message = await client.messages.create({
  model: "anthropic/claude-sonnet-4-6",
  max_tokens: 512,
  messages: [{ role: "user", content: "Explain this API in one sentence." }],
});

Response — message

{
  "id": "msg_…",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-4-6",
  "content": [{ "type": "text", "text": "" }],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": { "input_tokens": 18, "output_tokens": 24 }
}

Tool calls are returned as tool_use content blocks. Send their results back as tool_result blocks with the matching tool_use_id.

Streaming

With stream: true, the response is text/event-stream. Events follow this lifecycle:

message_start → content_block_start → content_block_delta
              → content_block_stop → message_delta → message_stop

Text deltas use text_delta; tool arguments use input_json_delta. A ping event may appear and should be ignored by clients that do not need heartbeats.

Errors

This endpoint uses the Messages error envelope:

{
  "type": "error",
  "error": { "type": "rate_limit_error", "message": "" }
}

Retry 429, 500 and 503 with exponential backoff and jitter. Do not retry validation, authentication or billing errors without changing the request or account state.

Last updated July 18, 2026

Was this page helpful?