/** * Zod schemas for the Anthropic Messages API request shape we accept on the * gateway. Mirrors https://docs.anthropic.com/en/api/messages — only the * shapes the gateway actually understands; unsupported fields are caught with * `.refine(...)` so the error mentions them explicitly. * * Used by `anthropic-messages.ts:parseRequest` to validate the inbound JSON * before walking it into pi-ai's canonical `Context`. */ import type { ContentBlockParam, ImageBlockParam, MessageCreateParams, MessageParam, TextBlockParam, Tool, ToolChoice } from "@anthropic-ai/sdk/resources/messages"; import * as z from "zod/v4"; export declare const cacheControlSchema: z.ZodObject<{ type: z.ZodLiteral<"ephemeral">; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>; export declare const base64ImageSourceSchema: z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>; export declare const urlImageSourceSchema: z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>; export declare const fileImageSourceSchema: z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>; export declare const imageSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; export declare const systemSchema: z.ZodOptional; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>>]>>; export declare const userMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"user">; content: z.ZodUnion; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image">; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodOptional; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image">; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">>]>>; is_error: z.ZodOptional; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>; export declare const assistantMessageSchema: z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodUnion; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"thinking">; thinking: z.ZodString; signature: z.ZodOptional; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"redacted_thinking">; data: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodOptional>; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>; export declare const messageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ role: z.ZodLiteral<"user">; content: z.ZodUnion; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image">; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodOptional; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image">; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">>]>>; is_error: z.ZodOptional; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodUnion; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"thinking">; thinking: z.ZodString; signature: z.ZodOptional; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"redacted_thinking">; data: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodOptional>; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>], "role">; export declare const toolSchema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; input_schema: z.ZodRecord; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>; export declare const toolChoiceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"auto">; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"any">; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"none">; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool">; name: z.ZodString; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>], "type">; export declare const thinkingConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"enabled">; budget_tokens: z.ZodNumber; display: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"disabled">; display: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"adaptive">; budget_tokens: z.ZodOptional; display: z.ZodOptional; }, z.core.$strip>], "type">; export declare const anthropicMessagesRequestSchema: z.ZodObject<{ model: z.ZodString; messages: z.ZodArray; content: z.ZodUnion; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image">; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodOptional; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"image">; source: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"base64">; data: z.ZodString; media_type: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"url">; url: z.ZodURL; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"file">; file_id: z.ZodString; }, z.core.$strip>], "type">; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">>]>>; is_error: z.ZodOptional; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>, z.ZodObject<{ role: z.ZodLiteral<"assistant">; content: z.ZodUnion; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"thinking">; thinking: z.ZodString; signature: z.ZodOptional; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"redacted_thinking">; data: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodOptional>; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>], "type">, z.ZodObject<{ type: z.ZodString; }, z.core.$loose>]>>]>; }, z.core.$strip>], "role">>; max_tokens: z.ZodNumber; system: z.ZodOptional; text: z.ZodString; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>>]>>; tools: z.ZodOptional; input_schema: z.ZodRecord; cache_control: z.ZodOptional; ttl: z.ZodOptional, z.ZodLiteral<"5m">]>>; }, z.core.$loose>>; }, z.core.$strip>>>; tool_choice: z.ZodOptional; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"any">; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"none">; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool">; name: z.ZodString; disable_parallel_tool_use: z.ZodOptional; }, z.core.$strip>], "type">>; temperature: z.ZodOptional; top_p: z.ZodOptional; top_k: z.ZodOptional; stop_sequences: z.ZodOptional>; stream: z.ZodOptional; thinking: z.ZodOptional; budget_tokens: z.ZodNumber; display: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"disabled">; display: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"adaptive">; budget_tokens: z.ZodOptional; display: z.ZodOptional; }, z.core.$strip>], "type">>; metadata: z.ZodOptional>; container: z.ZodOptional; context_management: z.ZodOptional; mcp_servers: z.ZodOptional; service_tier: z.ZodOptional; }, z.core.$strip>; /** * Public types are sourced from the upstream Anthropic SDK so the gateway * stays in lock-step with the canonical API surface; the schemas above are * runtime validators for the subset we actually accept. */ export type AnthropicMessagesRequest = MessageCreateParams; export type AnthropicSystem = MessageCreateParams["system"]; export type AnthropicMessage = MessageParam; export type AnthropicUserContentBlock = ContentBlockParam; export type AnthropicAssistantContentBlock = ContentBlockParam; export type AnthropicTool = Tool; export type AnthropicToolChoice = ToolChoice; export type AnthropicToolResultContent = TextBlockParam | ImageBlockParam;