SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
4.5 KB

# Anthropic — provider research

Last documentation audit: 2026-09-08 — sources: Claude Platform docs (Messages API, Models API, extended thinking, structured outputs, tool use, prompt caching, pricing, errors), the bundled claude-api reference (models table cached 2026-06-24), SDK type definitions of @anthropic-ai/sdk 0.124.0, and live probes with the owner key (scripts/provider-matrix.ts and GET /v1/models).

# Endpoint, auth, SDK

  • Base URL https://api.anthropic.com; headers x-api-key, anthropic-version: 2023-06-01. Invalid key → 401 authentication_error.
  • SDK @anthropic-ai/sdk 0.124.0 (client.messages.create({stream:true}) returns an async iterable of raw events; client.models.list() auto-paginates; client.messages.countTokens).
  • Timeouts: SDK default 10 min; PolyLLM uses 10 min for chats, 20 s for validation/listing; SDK retries 1 (PolyLLM never retries mid-stream).

# Models API (live capability metadata — verified)

GET /v1/models returns id, display_name, created_at, max_input_tokens, max_tokens, capabilities with thinking.types.{adaptive,enabled}, effort.{low,medium,high,xhigh,max}, image_input, pdf_input, structured_outputs, code_execution, citations, batch, context_management. 11 models for this key: claude-fable-5-1, claude-opus-5, claude-sonnet-5, claude-fable-5, claude-opus-4-8, claude-opus-4-7, claude-sonnet-4-6, claude-opus-4-6, claude-opus-4-5-20251101, claude-haiku-4-5-20251001, claude-sonnet-4-5-20250929. Aliases (claude-haiku-4-5) resolve to dated snapshots. All current models: 1M context (Haiku 4.5: 200k), 128k max output (Haiku 4.5: 64k).

# Verified rules encoded in the adapter

  • Adaptive-only generations (thinking.types.enabled.supported === false: Fable 5/5.1, Opus 5/4.8/4.7, Sonnet 5) reject temperature/top_p/top_k (400) and budget_tokens; the adapter exposes none of them. Effort via output_config.effort. Sending thinking:{type:"adaptive"} to Haiku 4.5 → 400 adaptive thinking is not supported on this model (probed) → Haiku uses {type:"enabled", budget_tokens} (≥1024, < max_tokens).
  • Fable 5.x: thinking always on, {type:"disabled"} → 400; forced tool_choice any/tool → 400 on Fable 5.1 (adapter downgrades to auto).
  • Adaptive thinking decides when to think: trivial prompts produce no thinking block and 0 thinking tokens even at effort high (probed on Sonnet 5); a harder prompt produced 3.5k thinking tokens with display:"summarized".
  • Streaming events: message_start (input usage incl. cache), content_block_start/delta/stop with text_delta, thinking_delta, signature_delta, input_json_delta, citations_delta; message_delta carries stop_reason (end_turn|max_tokens|stop_sequence|tool_use|pause_turn|refusal|model_context_window_exceeded), usage.output_tokens and usage.output_tokens_details.thinking_tokens; stop_details on refusal.
  • Tools: tools[{name, description, input_schema, strict}]; tool results as tool_result blocks in a user turn; thinking blocks replayed with signature only on the same model.
  • Server tools: web_search_20260209 (Opus 5/4.8/4.7/4.6, Sonnet 5/4.6; not combinable with code_execution_20260521), web_search_20250305 for older models.
  • Structured output: output_config.format = { type: "json_schema", schema } (Opus 4.7+, Sonnet 5, Fable — structured_outputs.supported).
  • Files: PDF as document (base64), text files as document with text/plain source; images base64 image blocks.
  • Errors: {type:"error", error:{type, message}}: authentication_error, permission_error, not_found_error, rate_limit_error, overloaded_error (529, retryable), billing_error, request_too_large, invalid_request_error.
  • Pricing (USD/M, first-party): Fable 5.1 10/50 (cache read 0.25), Opus 5 5/25, Sonnet 5 2/10, Sonnet 4.6 3/15, Haiku 4.5 1/5 — see catalog.ts; cache reads 10 % of input.
  • Prompt caching: cache_control (not used by PolyLLM v0.1; usage reports cache_read_input_tokens, folded into cached tokens).

# Probe results (2026-09-08, pnpm providers:matrix)

Auth ✅ · Model list ✅ (11) · Text ✅ · Streaming ✅ · System ✅ · Vision ✅ (64×64 PNG → "Red") · Tools ✅ (streamed input_json_delta, args rebuilt) · Structured output ✅ · Reasoning ✅ (Sonnet 5, effort high, 3 558 thinking tokens, summary streamed) · Token usage ✅ · Invalid key ✅ (401) · Error normalization ✅ (unknown model → not_found_error → MODEL_NOT_FOUND) · Long response ✅ (407 words).