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 pinstool_choice, then validates thetool_use.inputagainst the Pydantic model. (Claude has noresponse_formatlike OpenAI.) On models that don't accept forced tool use (Opus 5.5, Fable 5.1 and Mythos 5.1),parseautomatically usestool_choice="auto"+ strict tool use — transparent to you. See "What changed in 1.9.2". - Vision (
images=): images become animageblock with a base64source. - Documents (
files=): local text extraction.
What it does NOT do
- Audio transcription: the Claude API does not accept audio —
transcribe()raisesUnsupportedError. 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 noseed(it is dropped). max_tokensis 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
systemfield (not as a message). - Response (
Completion):usagefrom nativeinput_tokens/output_tokens;rawwith the SDK object. - Errors: 529 (overloaded) becomes
OverloadedError(a subtype ofServerError), 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_choiceof type"tool"/"any"returns 400. Since structured output relied on tool-forcing,parsebroke on them. Now, on those models only,parseusestool_choice="auto"+ strict tool use (Anthropic's recommended migration); every other Claude model keeps the usual tool-forcing. It's transparent: just callLLM("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 clearUnsupportedError(the API would reject it with 400). Usetool_choice="auto"— to enforce the argument schema, the lib already applies strict tool use on theparsepath.
What changed in 1.9.0
- Compatible with
anthropic>=1.0. SDK 1.0 removedtemperature,top_pandtop_kfrom themessages.create()signature — passing them raisedTypeError. The library now sends them in the body (extra_body), soLLM("anthropic", ..., temperature=0.2)works with any SDK version. - Extended thinking with tools across turns:
thinking/redacted_thinkingblocks (with signature) are preserved and resent before thetool_use, as the API requires. Inparse, thinking is turned off (a forcedtool_choiceis incompatible with it). - Native tools:
web_search,web_fetchandcode_execution(see Native tools); blocks withencrypted_contentgo back intact in the history andpause_turnis continued automatically. - Usage with cache:
input_tokensincludes cache tokens;cache_read_tokensandcache_write_tokensshow up with prompt caching, and the cost uses the cache price. - A refusal without
tool_useinparseraisesOutputValidationError(goes into failover); a response with no content becomesServerError.