You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a native Anthropic provider and stop sending Claude malformed requests
Two auto-reported session failures traced to the same place: Autohand sends
Claude requests that Anthropic rejects. The first named a model OpenRouter does
not serve; the second named a valid one and still failed, because OpenRouter
forwarded a payload Anthropic refused. Anthropic validates strictly and rejects
unsupported parameters rather than ignoring them, so anything we send loosely
comes back as an opaque 400.
Adds `anthropic` as a first-class provider on the official TypeScript SDK, with
the Messages API contract handled at the provider boundary: system prompts,
images, tool calls and results, structured output, adaptive thinking, and
Anthropic usage fields. The bundled catalog gains the current Claude lineup for
both the native provider and OpenRouter, and drops two OpenRouter IDs that never
existed. Setup, /model, /settings, ACP, and the answer-only RPC surface all know
about the provider.
Every optional request parameter is now gated on the target model. Temperature
is dropped for the Claude 5 family and Opus 4.7/4.8, output effort is clamped or
omitted where unsupported, and the thinking parameter is omitted entirely for
models that always think. Sending temperature unconditionally had been breaking
the default OpenRouter model on every request.
Thinking blocks are captured from each response and replayed unchanged on the
next one. Thinking level defaults to normal, which omits the parameter, but the
current models think adaptively regardless — so blocks come back every turn, and
dropping them risks ordering and signature rejections inside the tool loop.
`reasoningBlocks` is a provider-opaque passthrough on the message type, so other
providers needing the same replay contract can adopt it later.
Conversation history is repaired on the way out rather than trusted. A tool-only
assistant turn now sends null content instead of an empty string, which
aggregators translate into an empty text block; blank turns are dropped; blank
tool results become a placeholder; and tool calls or results orphaned by context
compaction are backfilled or removed. This is shared by OpenRouter and LLM
Gateway, and the equivalent repair is applied to Bedrock's Converse payload.
Vertex AI's native Claude branch was posting OpenAI-shaped messages, system role
included, straight to streamRawPredict. It could not have worked with a system
prompt. It now uses the shared Messages translation.
OpenRouter's error.metadata.raw carries the upstream provider's actual
complaint, while its own message is often the wrapper "Provider returned error".
Discarding it is why both reports were undiagnosable; it is now included, which
also lets a prompt-too-long rejection classify as context overflow and trigger
auto-compaction instead of failing the session.
Co-authored-by: Autohand Evolve <code-noreply@autohand.ai>
|**LLM Gateway**| Cloud | Pay-per-use | Low | Unified API for multiple providers |
59
61
|**DeepSeek**| Cloud | Pay-per-use | Low | DeepSeek V4 Flash and V4 Pro models |
@@ -150,21 +152,67 @@ OpenRouter provides a unified API to access 100+ models from various providers (
150
152
}
151
153
```
152
154
153
-
**Popular Models:**
155
+
**Current Anthropic Models:**
154
156
| Model | Description |
155
157
|-------|-------------|
156
-
|`your-modelcard-id-here`| Best balance of speed and capability |
157
-
|`anthropic/claude-5-opus`| Most capable Claude model |
158
+
|`anthropic/claude-sonnet-5`| Claude Sonnet 5 |
159
+
|`anthropic/claude-opus-5`| Claude Opus 5 |
160
+
|`anthropic/claude-fable-5`| Claude Fable 5 |
161
+
|`anthropic/claude-opus-4.8`| Claude Opus 4.8 |
162
+
|`anthropic/claude-haiku-4.5`| Claude Haiku 4.5 |
158
163
|`openai/gpt-5`| OpenAI's flagship model |
159
164
|`google/gemini-3.0-pro`| Google's latest model |
160
165
|`meta-llama/llama-3.1-70b-instruct`| Open-source alternative |
161
166
162
167
**Switching Models:**
163
168
164
169
```
165
-
/model anthropic/claude-5-opus
170
+
/model anthropic/claude-opus-5
166
171
```
167
172
173
+
**Claude models through OpenRouter:** OpenRouter forwards requests to Anthropic
174
+
largely unchanged, so Anthropic's stricter validation applies. Autohand omits
175
+
`temperature` for the Claude 5 family and Opus 4.7/4.8 (which reject sampling
176
+
parameters), requests extended thinking through OpenRouter's `reasoning` field,
177
+
and repairs turn shapes that Anthropic rejects — blank turns, blank tool
178
+
results, and tool calls or results orphaned by context compaction. When an
179
+
upstream provider does reject a request, the provider's own error text is now
180
+
included rather than only OpenRouter's generic "Provider returned error".
181
+
182
+
---
183
+
184
+
### Anthropic
185
+
186
+
The native Anthropic provider uses the official TypeScript SDK and the Messages API rather than routing Claude requests through the OpenAI-compatible provider layer. Native system prompts, images, tool calls, tool results, structured output, adaptive thinking, and Anthropic usage fields are translated at the provider boundary.
187
+
188
+
1. Create a key in the [Anthropic Console](https://console.anthropic.com/settings/keys).
189
+
2. Run `autohand --setup` or select Anthropic from `/model`.
190
+
3. Choose a model from the bundled and remotely updated catalog.
191
+
192
+
```json
193
+
{
194
+
"provider": "anthropic",
195
+
"anthropic": {
196
+
"apiKey": "sk-ant-your-key-here",
197
+
"baseUrl": "https://api.anthropic.com",
198
+
"model": "claude-sonnet-5",
199
+
"contextWindow": 1000000
200
+
}
201
+
}
202
+
```
203
+
204
+
Current catalog choices include `claude-sonnet-5`, `claude-opus-5`, `claude-fable-5`, `claude-opus-4-8`, `claude-sonnet-4-6`, and `claude-haiku-4-5`. Use the unprefixed model IDs for the native provider; use `anthropic/...` IDs only with OpenRouter.
205
+
206
+
**Request behavior:**
207
+
208
+
- Anthropic rejects unsupported parameters with a `400` rather than ignoring them, so Autohand gates each optional parameter on the selected model. `temperature` is dropped for the Claude 5 family and Opus 4.7/4.8, `output_config.effort` is clamped to `high` on Opus 4.5/4.6 and omitted for models without effort support, and `thinking` is omitted entirely for models where thinking is always on.
209
+
- Prompt caching is on by default. The stable prefix (tools, system prompt, and prior turns) is cached automatically; check `/usage` for cache read and write counts.
210
+
- Thinking blocks are captured from each response and replayed unchanged on the following request. Anthropic validates their ordering and signatures, so they are never edited or reconstructed.
211
+
- Only the leading system messages become the top-level `system` prompt. Later system notes stay in conversation order as `<system-reminder>` blocks so the cached prefix is not invalidated mid-session.
212
+
- Requests use a 10-minute floor for the client timeout because the Anthropic SDK applies `network.timeout` to the whole request, not just the response headers. A larger `network.timeout` is honored; a smaller one is not.
213
+
214
+
See Anthropic's [model overview](https://platform.claude.com/docs/en/about-claude/models/overview) and [TypeScript Messages API](https://platform.claude.com/docs/en/api/typescript/messages/create) for the upstream contracts.
215
+
168
216
---
169
217
170
218
### OpenAI
@@ -238,8 +286,8 @@ LLM Gateway provides a unified API for multiple LLM providers with a single inte
238
286
|`gpt-5`| OpenAI |
239
287
|`gpt-5-mini`| OpenAI |
240
288
|`gpt-4-turbo`| OpenAI |
241
-
|`claude-5-sonnet`| Anthropic |
242
-
|`claude-5-haiku`| Anthropic |
289
+
|`claude-sonnet-5`| Anthropic |
290
+
|`claude-haiku-4-5`| Anthropic |
243
291
|`gemini-3.0-pro`| Google |
244
292
|`gemini-3.0-flash`| Google |
245
293
@@ -608,7 +656,7 @@ Use the `/model` command to switch providers or models:
608
656
```
609
657
/model # List available models
610
658
/model gpt-5 # Switch to GPT-5
611
-
/model anthropic/claude-5-opus # Switch to Claude Opus
659
+
/model anthropic/claude-opus-5 # Switch OpenRouter to Claude Opus 5
612
660
```
613
661
614
662
When you pick `openai`, Autohand now lets you choose between `API key` and `ChatGPT account` authentication.
0 commit comments