Skip to content

Anthropic Messages API (Native)

Native Anthropic Messages endpoint — use the official anthropic Python SDK or anthropic-sdk-go directly against JarvisClaw. No format conversion, full feature parity with Claude's native API including prompt caching, extended thinking, and streaming.

Base URL: https://api.jarvisclaw.ai

Authentication

MethodHeaderDescription
API Keyx-api-key: sk-...Anthropic-style header. Platform routes and handles x402 settlement
Private Key (x402)Automatic via SDKAgent signs x402 directly from its own wallet

Endpoint

POST /v1/messages

Create a message using Anthropic's native protocol. Supports all Claude models.

Quick Start

python
import anthropic

client = anthropic.Anthropic(
    api_key="sk-your-api-key",
    base_url="https://api.jarvisclaw.ai"
)

message = client.messages.create(
    model="claude-sonnet-4.6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain quantum computing in one paragraph"}
    ]
)
print(message.content[0].text)
go
package main

import (
    "context"
    "fmt"
    "github.com/anthropics/anthropic-sdk-go"
    "github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
    client := anthropic.NewClient(
        option.WithAPIKey("sk-your-api-key"),
        option.WithBaseURL("https://api.jarvisclaw.ai"),
    )

    message, _ := client.Messages.New(context.Background(),
        anthropic.MessageNewParams{
            Model:     "claude-sonnet-4.6",
            MaxTokens: 1024,
            Messages: []anthropic.MessageParam{
                anthropic.NewUserMessage(
                    anthropic.NewTextBlock("Explain quantum computing in one paragraph"),
                ),
            },
        },
    )
    fmt.Println(message.Content[0].Text)
}
bash
curl https://api.jarvisclaw.ai/v1/messages \
  -H "x-api-key: sk-your-api-key" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4.6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain quantum computing in one paragraph"}
    ]
  }'

Streaming

python
import anthropic

client = anthropic.Anthropic(
    api_key="sk-your-api-key",
    base_url="https://api.jarvisclaw.ai"
)

with client.messages.stream(
    model="claude-sonnet-4.6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Write a short story about an AI agent"}
    ]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
go
package main

import (
    "context"
    "fmt"
    "github.com/anthropics/anthropic-sdk-go"
    "github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
    client := anthropic.NewClient(
        option.WithAPIKey("sk-your-api-key"),
        option.WithBaseURL("https://api.jarvisclaw.ai"),
    )

    stream := client.Messages.NewStreaming(context.Background(),
        anthropic.MessageNewParams{
            Model:     "claude-sonnet-4.6",
            MaxTokens: 1024,
            Messages: []anthropic.MessageParam{
                anthropic.NewUserMessage(
                    anthropic.NewTextBlock("Write a short story about an AI agent"),
                ),
            },
        },
    )
    defer stream.Close()

    for stream.Next() {
        evt := stream.Current()
        switch evt := evt.AsAny().(type) {
        case anthropic.ContentBlockDeltaEvent:
            if evt.Delta.Type == "text_delta" {
                fmt.Print(evt.Delta.Text)
            }
        }
    }
}
bash
curl https://api.jarvisclaw.ai/v1/messages \
  -H "x-api-key: sk-your-api-key" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4.6",
    "max_tokens": 1024,
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a short story about an AI agent"}
    ]
  }'

Extended Thinking

Enable Claude's internal reasoning for complex tasks:

python
message = client.messages.create(
    model="claude-sonnet-4.6",
    max_tokens=16000,
    thinking={
        "type": "enabled",
        "budget_tokens": 10000
    },
    messages=[
        {"role": "user", "content": "What is the 100th prime number? Think step by step."}
    ]
)

for block in message.content:
    if block.type == "thinking":
        print(f"[Thinking]: {block.thinking}")
    elif block.type == "text":
        print(f"[Answer]: {block.text}")
go
message, _ := client.Messages.New(ctx, anthropic.MessageNewParams{
    Model:     "claude-sonnet-4.6",
    MaxTokens: 16000,
    Thinking: &anthropic.ThinkingConfigParam{
        Type:        "enabled",
        BudgetTokens: 10000,
    },
    Messages: []anthropic.MessageParam{
        anthropic.NewUserMessage(
            anthropic.NewTextBlock("What is the 100th prime number? Think step by step."),
        ),
    },
})

Tool Use (Function Calling)

python
message = client.messages.create(
    model="claude-sonnet-4.6",
    max_tokens=1024,
    tools=[{
        "name": "get_weather",
        "description": "Get current weather for a location",
        "input_schema": {
            "type": "object",
            "properties": {
                "location": {"type": "string", "description": "City name"}
            },
            "required": ["location"]
        }
    }],
    messages=[
        {"role": "user", "content": "What's the weather in Tokyo?"}
    ]
)

# Handle tool_use blocks in response
for block in message.content:
    if block.type == "tool_use":
        print(f"Tool: {block.name}, Input: {block.input}")
go
message, _ := client.Messages.New(ctx, anthropic.MessageNewParams{
    Model:     "claude-sonnet-4.6",
    MaxTokens: 1024,
    Tools: []anthropic.ToolParam{{
        Name:        "get_weather",
        Description: "Get current weather for a location",
        InputSchema: map[string]any{
            "type": "object",
            "properties": map[string]any{
                "location": map[string]any{"type": "string", "description": "City name"},
            },
            "required": []string{"location"},
        },
    }},
    Messages: []anthropic.MessageParam{
        anthropic.NewUserMessage(
            anthropic.NewTextBlock("What's the weather in Tokyo?"),
        ),
    },
})

System Prompt

python
message = client.messages.create(
    model="claude-sonnet-4.6",
    max_tokens=1024,
    system="You are a helpful coding assistant. Always provide working examples.",
    messages=[
        {"role": "user", "content": "How do I read a file in Python?"}
    ]
)

Body Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g., claude-sonnet-4.6)
messagesarrayYesArray of message objects with role and content
max_tokensintegerYesMaximum tokens to generate
systemstring/arrayNoSystem prompt
streambooleanNoStream via SSE (default: false)
temperaturenumberNoSampling temperature (0-1)
top_pnumberNoNucleus sampling
top_kintegerNoTop-K sampling
stop_sequencesarrayNoCustom stop sequences
toolsarrayNoTool definitions for function calling
tool_choiceobjectNo{"type": "auto"}, {"type": "any"}, {"type": "tool", "name": "..."}
thinkingobjectNo{"type": "enabled", "budget_tokens": N}
metadataobjectNo{"user_id": "..."} for abuse tracking

Required Headers

HeaderValueDescription
x-api-keysk-...Your API key
anthropic-version2023-06-01API version (required for curl, SDKs set automatically)
Content-Typeapplication/jsonRequest format

Streaming Events

Event TypeDescription
message_startMessage object with metadata and usage
content_block_startNew content block (text, tool_use, thinking)
content_block_deltaIncremental text or JSON delta
content_block_stopContent block finished
message_deltaStop reason and final usage
message_stopMessage complete

Model Names

When using the native Anthropic endpoint, model names do not need the anthropic/ prefix:

ModelID
Claude Opus 4.8claude-opus-4.8
Claude Opus 4.7claude-opus-4.7
Claude Sonnet 4.6claude-sonnet-4.6
Claude Sonnet 4.5claude-sonnet-4.5
Claude Haiku 4.5claude-haiku-4.5

The fully-qualified anthropic/claude-… forms work too. Older dated IDs such as claude-sonnet-4-20250514 are not in the current catalogue — check Models or GET /v1/models for the live list.

See Also