Cameleer

Anthropic component

The anthropic component calls Claude models through the Anthropic Messages API, with tool calling: with tags it runs your ai-tool routes for the model, and it is a model for the agent step.

Scheme: anthropic: · Crate: cameleer-saas · Cargo feature: saas · Consumer: no · Producer: yes · Apache Camel: no direct equivalent (Camel reaches Claude through LangChain4j)

When to use it

  • Call Claude directly, without Bedrock or Vertex AI.
  • Give Claude your routes as tools, with argument checks, approvals and an audit log (ai-tool).
  • Use Claude as the model of an agent step.

URI format

text
anthropic:messages[?options]

Example

yaml example: anthropic-tools
- route:
    from:
      uri: direct:ask
      steps:
        - to: "anthropic:messages?model=claude-sonnet-4-5&apiKey={{env:ANTHROPIC_API_KEY}}&systemMessage=You are a support agent.&tags=support"

A text body is the user's message and becomes the answer. With tags, the model can call the ai-tool routes with those tags; the loop runs them and sends the results back until Claude answers.

Options

optiondefaultdescription
modelrequiredThe model, such as claude-sonnet-4-5 (the CamelAnthropicModel header overrides it)
apiKeyANTHROPIC_API_KEY envSent as x-api-key
baseUrlhttps://api.anthropic.comThe API base URL (a gateway or proxy)
anthropicVersion2023-06-01The anthropic-version header
systemMessageThe system prompt (the CamelAnthropicSystemMessage header overrides it)
maxTokens1024max_tokens (required by the API)
temperatureSampling temperature
promptCachingautoauto puts cache_control breakpoints on the last tool, the system prompt and the last message, so the next turn reads the stable prefix from Anthropic's cache (about a tenth of the input price); off sends the request unchanged
timeout120sHTTP timeout
tags, autoToolExecution, maxToolIterations, maxAgenticTokens, parallelToolExecution, hallucinatedToolNameStrategy, record, replayTool calling, as on every model component (the options)
maxRetries, retryDelay, fallbackModels, responseCache, responseCacheTtl, responseCacheSize, coalesceRetries, fallbacks, response cache and coalescing (model providers)

Message headers

headerdirectiondescription
CamelAnthropicSystemMessageinThe system prompt
CamelAnthropicModelinThe model for this call
CamelAnthropicStopReasonoutend_turn, or why the tool loop stopped
CamelAnthropicInputTokens, CamelAnthropicOutputTokensoutToken usage (all turns of a tool loop)
CamelAiAgentTurns, CamelAiAgentToolCalls, CamelAiAgentStopReason, CamelAiAgentTotalTokensoutThe tool loop
CamelAiRequestedToolCallsoutWith autoToolExecution=false: the calls Claude asked for
CamelAiCacheReadTokens, CamelAiCacheWriteTokensoutInput tokens read from and written to the prompt cache (when there were any)

Bodies: a text body is one user message; a list body is the message list ({"role", "content"}); a map body is sent as the whole request (model and max_tokens are added when missing) and the whole response becomes the body.

Common questions

What happens on an API error?

The exchange fails with HttpOperationFailedException and the API's error message.

Can I test routes that use it without calling Claude?

Yes. Record the responses once (record=file:claude.jsonl) and replay them (replay=...), or write the responses by hand; cameleer test runs the route against them (testing without a model). cameleer_saas::testing::AnthropicMock is a mock of the Messages API for Rust tests.

Found a problem?

If something on this page doesn't match what Cameleer does, please open an issue, or fork the repository, fix it, add a test, run cargo test --workspace and open a pull request.

Edit this page on GitHub