Jangada AIJangada AI

Anthropic (Claude)

Provider anthropic. Adapter over the anthropic SDK.

pip install "jangada-ai[anthropic]"
  • provider=: "anthropic"
  • Environment variable: ANTHROPIC_API_KEY
from jangada_ai import LLM
llm = LLM("anthropic", "claude-opus-4-8")

What it does

  • Text and streaming.
  • Structured output (parse): via tool-forcing — it defines a tool with the schema and pins tool_choice, then validates the tool_use.input against the Pydantic model. (Claude has no response_format like OpenAI.) On models that don't accept forced tool use (Opus 5.5, Fable 5.1 and Mythos 5.1), parse automatically uses tool_choice="auto" + strict tool use — transparent to you. See "What changed in 1.9.2".
  • Vision (images=): images become an image block with a base64 source.
  • Documents (files=): local text extraction.

What it does NOT do

  • Audio transcription: the Claude API does not accept audio — transcribe() raises UnsupportedError. Use OpenAI, Groq, or Gemini for audio (and, if you want, keep Claude as the text provider with audio fallback on another). See Audio transcription.
  • Object detection: it works mechanically (vision + structured), but the coordinate accuracy is lower than Gemini's.

Structure and quirks

  • Parameters: temperature, max_tokens, top_p, top_k, stop (→ stop_sequences). It has no seed (it is dropped).
  • max_tokens is required in the Claude API — jangada already uses a default high value (8192) when you don't provide one.
  • System: goes in the request's system field (not as a message).
  • Response (Completion): usage from native input_tokens/output_tokens; raw with the SDK object.
  • Errors: 529 (overloaded) becomes OverloadedError (a subtype of ServerError), eligible for retry/fallback. See Errors.

Related: Capability matrix, Structured output.

What changed in 1.9.2

  • Compatible with Claude Opus 5.5, Fable 5.1 and Mythos 5.1 (released 2026-09-22). These models bring a breaking change: forced tool use is no longer accepted — a tool_choice of type "tool"/"any" returns 400. Since structured output relied on tool-forcing, parse broke on them. Now, on those models only, parse uses tool_choice="auto" + strict tool use (Anthropic's recommended migration); every other Claude model keeps the usual tool-forcing. It's transparent: just call LLM("anthropic", "claude-opus-5-5").parse(...) as usual.
  • complete(tools=…, tool_choice="required" (or "any"/a name) on Opus 5.5 / Fable 5.1 / Mythos 5.1 now raises a clear UnsupportedError (the API would reject it with 400). Use tool_choice="auto" — to enforce the argument schema, the lib already applies strict tool use on the parse path.

What changed in 1.9.0

  • Compatible with anthropic>=1.0. SDK 1.0 removed temperature, top_p and top_k from the messages.create() signature — passing them raised TypeError. The library now sends them in the body (extra_body), so LLM("anthropic", ..., temperature=0.2) works with any SDK version.
  • Extended thinking with tools across turns: thinking/redacted_thinking blocks (with signature) are preserved and resent before the tool_use, as the API requires. In parse, thinking is turned off (a forced tool_choice is incompatible with it).
  • Native tools: web_search, web_fetch and code_execution (see Native tools); blocks with encrypted_content go back intact in the history and pause_turn is continued automatically.
  • Usage with cache: input_tokens includes cache tokens; cache_read_tokens and cache_write_tokens show up with prompt caching, and the cost uses the cache price.
  • A refusal without tool_use in parse raises OutputValidationError (goes into failover); a response with no content becomes ServerError.

On this page