AIX: Anthropic: minor API changes

This commit is contained in:
Enrico Ros
2026-02-06 19:18:54 -08:00
parent c72e3c58dd
commit aa697edb8c
3 changed files with 16 additions and 23 deletions
+1 -1
View File
@@ -497,8 +497,8 @@ export namespace AixWire_API {
*/
userGeolocation: z.object({
city: z.string().optional(), // free text input for the city of the user, e.g. San Francisco.
country: z.string().optional(), // two-letter ISO country code of the user, e.g. US
region: z.string().optional(), // free text input for the reg. of the user the user, e.g. California
country: z.string().optional(), // two-letter ISO country code of the user, e.g. US
timezone: z.string().optional(), // IANA timezone of the user, e.g. America/Los_Angeles
}).optional(),
});
@@ -136,6 +136,9 @@ export function aixToAnthropicMessageCreate(model: AixAPI_Model, _chatGenerate:
const areToolCallsRequired = payload.tool_choice && typeof payload.tool_choice === 'object' && (payload.tool_choice.type === 'any' || payload.tool_choice.type === 'tool');
const canUseThinking = !areToolCallsRequired || !hotFixDisableThinkingWhenToolsForced;
if (model.vndAntThinkingBudget !== undefined && canUseThinking) {
// NOTE: We don't want to maintain patches here - so just FYI: budget_tokens is deprecated on Opus 4.6 in favor of adaptive thinking
// if (typeof model.vndAntThinkingBudget === 'number' && model.id.includes('opus-4-6'))
// console.warn('[Anthropic] budget_tokens is deprecated on Opus 4.6 - use adaptive thinking instead');
payload.thinking = model.vndAntThinkingBudget === 'adaptive' ? {
type: 'adaptive',
} : model.vndAntThinkingBudget !== null ? {
@@ -187,6 +190,10 @@ export function aixToAnthropicMessageCreate(model: AixAPI_Model, _chatGenerate:
type: 'web_search_20250305',
name: 'web_search',
max_uses: 10, // Allow up to 10 progressive searches // FIXME: HARDCODED
// Pass user geolocation for location-aware search results
...(model.userGeolocation ? {
user_location: { type: 'approximate' as const, ...model.userGeolocation },
} : {}),
});
}
@@ -52,29 +52,15 @@ const DEFAULT_ANTHROPIC_HEADERS = {
const DEFAULT_ANTHROPIC_BETA_FEATURES: string[] = [
// NOTE: undocumented: I wonder what this is for
// 'claude-code-20250219',
// Known SDK beta headers (for reference, not all used):
// prompt-caching-2024-07-31 -- GA: no longer needed
// pdfs-2024-09-25 -- GA: no longer needed
// token-efficient-tools-2025-02-19 -- not used; disabled for now as side-effects are untested
// extended-cache-ttl-2025-04-11 -- for 1h cache TTL; we support ttl:'1h' in wiretypes already
// interleaved-thinking-2025-05-14 -- for Claude 4/4.5 interleaved thinking (auto on Opus 4.6 adaptive)
// context-management-2025-06-27 -- for context_management edits (e.g. clear_tool_uses)
// model-context-window-exceeded-2025-08-26 -- Sonnet 4.5+ have this by default
// NOTE: disabled for now, as we don't have tested side-effects for this feature yet
// 'token-efficient-tools-2025-02-19', // https://docs.anthropic.com/en/docs/build-with-claude/tool-use/token-efficient-tool-use
/**
* to use the prompt caching feature; adds to any API invocation:
* - message_start.message.usage.cache_creation_input_tokens: number
* - message_start.message.usage.cache_read_input_tokens: number
*/
'prompt-caching-2024-07-31',
/**
* Enables model_context_window_exceeded stop reason for models earlier than Sonnet 4.5
* (Sonnet 4.5+ have this by default). This allows requesting max tokens without calculating
* input size, and the API will return as much as possible within the context window.
* https://docs.claude.com/en/api/handling-stop-reasons#model-context-window-exceeded
*/
// 'model-context-window-exceeded-2025-08-26',
// now default
// 'messages-2023-12-15'
] as const;
const PER_MODEL_BETA_FEATURES: { [modelId: string]: string[] } = {