Files
MealQuest/internal/ai/llm/anthropic/testdata/models_page2.json
T
dev_agentandClaude Opus 5.5 3b36f07cb8 Feature 08 task 3: Anthropic Messages adapter
Add internal/ai/llm/anthropic, an llm.Provider over plain net/http:

- POST {base}/v1/messages and GET {base}/v1/models with x-api-key and
  anthropic-version 2023-06-01. An empty key, a non-positive
  Config.MaxTokens and a base URL that is not absolute http(s), or that
  carries userinfo, a query or a fragment, are construction errors.
- System text goes in the top-level system field. A Request with a
  Schema becomes one tool whose input_schema is the schema, forced by
  tool_choice; Response.JSON is that tool's input. Otherwise the text
  blocks are Response.Text. Usage and stop_reason are parsed.
- ListModels follows has_more/after_id pages; Verify fetches one page
  with limit=1.
- 401/403 map to ErrAuth, 429 and 529 to ErrRateLimited with
  Retry-After, 408 and deadlines to ErrTimeout, other statuses to
  ErrProvider with a redacted excerpt.
- Errors carry the OpenAI adapter's redaction chain, so no Error(),
  Unwrap layer, errors.As target or %#v output holds the key.

Contract tests replay sanitized fixtures adapted from Anthropic's public
Messages API docs over httptest, covering tool-forced JSON, text, each
error mapping and key redaction with the keys x-api-key, anthropic,
HTTP, rate, a one-letter key and a URL-escaped key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 07:49:52 -04:00

19 lines
387 B
JSON

{
"data": [
{
"type": "model",
"id": "claude-haiku-4-5-20251001",
"display_name": "Claude Haiku 4.5",
"created_at": "2025-10-01T00:00:00Z"
},
{
"type": "model",
"id": "claude-opus-5-5",
"created_at": "2026-05-01T00:00:00Z"
}
],
"has_more": false,
"first_id": "claude-haiku-4-5-20251001",
"last_id": "claude-opus-5-5"
}