Back to Eliza

Messages

packages/cloud-frontend/content/api/messages.mdx

2.0.13.6 KB
Original Source

import { Callout, Tabs } from "@/docs/components";

Messages

<div className="status-badge status-stable">Stable</div>

Anthropic-compatible POST /api/v1/messages for Claude Code and other clients that expect the Anthropic Messages API.

Endpoint

<div className="api-endpoint"> <span className="method-badge method-badge-post">POST</span> <span className="path">/api/v1/messages</span> </div>

Authentication

Use your Cloud API key with either Authorization: Bearer ... or X-API-Key.

Claude Code and Anthropic SDK clients should also send:

  • anthropic-version: 2023-06-01
  • Content-Type: application/json

Example

<Tabs items={['cURL', 'Claude Code']}> <Tabs.Tab>

bash
curl -X POST "https://elizacloud.ai/api/v1/messages" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "summarize my priorities for today" }
        ]
      }
    ]
  }'

</Tabs.Tab> <Tabs.Tab>

bash
export ANTHROPIC_BASE_URL="https://elizacloud.ai/api/v1"
export ANTHROPIC_API_KEY="YOUR_API_KEY"
claude

</Tabs.Tab> </Tabs>

Supported Fields

FieldTypeRequiredNotes
modelstringyesAccepts Anthropic-style model ids such as claude-sonnet-4-6
max_tokensintegeryesOutput token cap
messagesarrayyesAnthropic message array
systemstring or arraynoAnthropic system prompt format
streambooleannoEmits Anthropic SSE events
temperaturenumbernoPassed through when supported
top_pnumbernoPassed through when supported
top_knumbernoPassed through when supported
stop_sequencesarraynoAnthropic stop sequences
toolsarraynoAnthropic tool definitions
tool_choiceobjectnoauto, any, none, or a named tool

Message Content

Supported content blocks:

  • { "type": "text", "text": "..." }
  • { "type": "image", "source": { "type": "url", "url": "..." } }
  • { "type": "image", "source": { "type": "base64", "media_type": "image/png", "data": "..." } }
  • { "type": "tool_use", "id": "...", "name": "...", "input": { ... } }
  • { "type": "tool_result", "tool_use_id": "...", "content": "..." }

Streaming

When stream: true, the route emits Anthropic-style SSE events such as:

  • message_start
  • content_block_start
  • content_block_delta
  • content_block_stop
  • message_delta
  • message_stop
  • error

Tool calls stream as Anthropic tool_use content blocks so Claude Code can continue multi-step workflows.

<Callout type="info"> This route is intended as a compatibility layer. Billing, auth, moderation, and credit enforcement still run through elizaOS Cloud. </Callout>