Skip to content

Commit 9593342

Browse files
tombeckenhamclaude
andcommitted
chore(ai-openrouter): clarify changeset, tidy image error check, document common options
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b094d8b commit 9593342

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

.changeset/giant-garlics-crash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Derive `text-provider-options` types from the SDK's `ChatRequest` so provider options stay in lockstep with the SDK surface
88
- Drop `topK` / `topA` / `minP` / `repetitionPenalty` / `includeReasoning` / `verbosity` / `webSearchOptions` from `OpenRouterBaseOptions` now that the SDK narrows `ChatRequest` to OpenAI-compatible fields — callers passing these previously saw them silently stripped at runtime, and now get a TypeScript error instead
99
- Add those same keys to `excludedParams` in the model-catalog generator so future syncs don't reintroduce them
10-
- Add native structured output support using JSON Schema response formats
10+
- Switch `structuredOutput` to the SDK's native `responseFormat: { type: 'json_schema' }` instead of coercing the model via a forced `structured_output` tool call — the schema now flows straight to the provider, yielding cleaner responses and dropping the dummy-tool round-trip
1111
- Refactor options passthrough to use camelCase naming convention
1212
- Refresh the model catalog with the latest OpenRouter models (Opus 4.6, Sonnet 4.6, Gemini 3.1 Pro, etc.) and remove the deprecated `openrouter/auto` model
1313
- Unify the outbound request payload envelope

packages/typescript/ai-openrouter/src/adapters/image.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ export class OpenRouterImageAdapter<
9898
},
9999
})
100100

101-
const maybeError = (response as { error?: unknown }).error
102-
if (maybeError) {
101+
// Check for error in response
102+
if ('error' in response && response.error) {
103+
const { error } = response
103104
const errorMsg =
104-
typeof maybeError === 'object' && 'message' in maybeError
105-
? String((maybeError as { message: unknown }).message)
106-
: String(maybeError)
105+
typeof error === 'object' && 'message' in error
106+
? String(error.message)
107+
: String(error)
107108
throw new Error(`Image generation failed: ${errorMsg}`)
108109
}
109110

packages/typescript/ai-openrouter/src/text/text-provider-options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ export type OpenRouterCommonOptions = Pick<
5757
| 'parallelToolCalls'
5858
| 'modalities'
5959
> & {
60+
/**
61+
* A list of model IDs to use as fallbacks if the primary model is unavailable.
62+
*/
6063
models?: Array<OpenRouterChatModel>
64+
/**
65+
* The model variant to use, if supported by the model.
66+
* Will be appended to the model ID.
67+
*/
6168
variant?: 'free' | 'nitro' | 'online' | 'exacto' | 'extended' | 'thinking'
6269
}
6370

0 commit comments

Comments
 (0)