Skip to content

anthropic://

Anthropic Claude — native Messages API (POST /v1/messages), distinct from the OpenAI shape. Sends a single user turn (with an optional system prompt) and writes the assistant text back onto the exchange body. Use this for Claude models specifically; for OpenAI's chat API shape see openai, and for the broader provider comparison see the providers guide.

URI shape

anthropic://chat?model=<id>&apiKey=<key>&temperature=<float>&maxTokens=<int>&baseURL=<url>

The path token after anthropic:// is informational — the only operation is chat. embeddings is not supported on this scheme (use a dedicated embedding provider).

Parameters

Param Type Default Producer/Consumer/Both Description
model string claude-sonnet-4-20250514 Producer Anthropic model id. See Anthropic's model catalogue for current choices.
apiKey string (from constructor) Producer Anthropic API key. Sent as the x-api-key header (NOT Authorization: Bearer).
baseURL string https://api.anthropic.com Producer Override for proxies or regional endpoints.
temperature float 0.7 Producer Sampling temperature.
maxTokens int 4096 Producer Hard cap on completion tokens. Sent as max_tokens (required by Anthropic — there is no "no cap" mode).

Producer-only — no consumer.

Headers

The producer reads:

Header Effect
systemPrompt Sent as the top-level system field of the Messages request (not as a message turn).

After a successful call, the producer sets:

Header Description
anthropic.model The model id used.
anthropic.id Anthropic message id (msg_...).
anthropic.stopReason end_turn, max_tokens, stop_sequence, etc.
anthropic.usage.inputTokens Tokens billed for the prompt.
anthropic.usage.outputTokens Tokens billed for the completion.

Examples

Basic chat call:

- id: claude-summary
  from: direct://summarize
  steps:
    - to: anthropic://chat?model=claude-sonnet-4-20250514&apiKey=${ANTHROPIC_API_KEY}

With a system prompt:

- id: claude-with-system
  from: direct://classify
  steps:
    - setHeader:
        name: systemPrompt
        starlang: |
          %sl 2.0
          output text/plain
          ---
          "You are a classification engine. Respond only with one of: SPAM, HAM, UNSURE."
    - to: anthropic://chat?model=claude-haiku-4-20250514&apiKey=${ANTHROPIC_API_KEY}&temperature=0&maxTokens=8

Pin to a longer-context tier:

- to: anthropic://chat?model=claude-opus-4-20250514&maxTokens=16384&apiKey=${ANTHROPIC_API_KEY}

Behavior notes

  • Headers differ from OpenAI. Anthropic uses x-api-key and requires the static anthropic-version: 2023-06-01 header — both are set automatically.
  • max_tokens is required by the Anthropic API. The component always sends maxTokens (default 4096).
  • No streaming, no vision, no tool-use on this raw client — for rich features use the agent step with the Anthropic LLM provider in pkg/agent/llm.
  • 120s timeout on the underlying http.Client. No retries; wrap in a resilience processor if you need them.
  • Single-turn. Multi-turn history must be managed by the caller — see the agent memory layer.
  • Response body is text extracted from all type: "text" content blocks concatenated.

Multimodal input

anthropic:// accepts images alongside text via the same Helix-only headers used by every LLM component. Use a vision-capable model (claude-3-5-sonnet-*, claude-3-opus-*, claude-3-haiku-*) — older models without vision will return a 400.

Body Headers What gets sent
string or []byte (non-image) — Single type:"text" block (back-compat).
[]byte w/ image magic (PNG/JPEG/GIF/WEBP/…) HelixLLMSystemPrompt for the prompt type:"image" block with source:{type:"base64", media_type:"image/png", data:"…"}.
Any text body HelixLLMImages = []string of URLs URL-source images (source:{type:"url", url:"…"}) + the text block.
*exchange.MultipartContent — Pass-through, in order.

HelixLLMImageDetail is OpenAI-specific and ignored here — Anthropic auto-selects detail from the image data.

- set-header:
    name: HelixLLMSystemPrompt
    constant: "Caption the clinical content. Avoid speculation."
- to: anthropic://?model=claude-3-5-sonnet-latest&apiKey=${env:ANTHROPIC_API_KEY}
  # body: PNG bytes from upstream

Source

  • pkg/component/anthropic/anthropic.go
  • pkg/component/anthropic/anthropic_test.go

See also