import { type AIMLAPIClient } from '../client'; /** * Message role types */ export type MessageRole = 'user' | 'assistant' | 'system'; /** * Message content types */ export type MessageContent = string | Array<{ type: 'text' | 'image' | 'tool_use' | 'tool_result' | 'thinking' | 'redacted_thinking'; text?: string; source?: { type: 'base64'; media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'; data: string; }; tool_use?: { id: string; name: string; input: Record; }; tool_result?: { tool_use_id: string; is_error?: boolean; content?: string | Array<{ type: 'text' | 'image'; text?: string; source?: { type: 'base64'; media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'; data: string; }; }>; }; thinking?: string; signature?: string; data?: string; }>; /** * Message stop sequence */ export type MessageStopSequence = 'content' | 'tool_use' | 'max_tokens' | 'timeout' | 'stop_sequence'; /** * Delta for streaming responses */ export interface MessageDelta { type: 'content_block_delta'; index: number; delta: { type: 'text_delta' | 'input_json_delta'; text?: string; partial_json?: string; }; } /** * Message usage */ export interface MessageUsage { input_tokens: number; output_tokens: number; } /** * Message response */ export interface MessageResponse { id: string; type: 'message'; role: 'assistant'; content: Array<{ type: 'text' | 'image' | 'tool_use' | 'tool_result' | 'thinking'; text?: string; source?: { type: 'base64' | 'url'; media_type: string; data: string; }; name?: string; input?: Record; thinking?: string; thinking_duration_ms?: number; }>; model: string; stop_reason: MessageStopSequence | 'max_tokens' | 'timeout' | string; stop_sequence?: MessageStopSequence; usage: MessageUsage; } /** * Streaming event types */ export type MessageStreamEvent = { type: 'message_start'; message: MessageResponse; } | { type: 'content_block_start'; content_block: MessageResponse['content'][0]; } | { type: 'content_block_delta'; delta: MessageDelta; } | { type: 'content_block_stop'; index: number; } | { type: 'message_delta'; delta: { stop_reason?: string; usage?: MessageUsage; }; } | { type: 'message_stop'; stop_reason: string; }; /** * Tool choice types */ export type ToolChoice = { type: 'auto'; } | { type: 'any'; } | { type: 'tool'; name: string; } | { type: 'none'; }; /** * Tool definition */ export interface Tool { name: string; description?: string; input_schema: { type: 'object'; properties?: Record; required?: string[]; additionalProperties?: boolean | null; }; } /** * Thinking configuration */ export interface Thinking { type: 'enabled'; budget_tokens: number; } /** * Messages API parameters */ export interface MessagesParams { /** * The model to use for the message. */ model: string; /** * The messages to send. */ messages: Array<{ role: MessageRole; content: MessageContent; }>; /** * Maximum number of tokens to generate. */ max_tokens?: number | null; /** * Temperature for sampling. */ temperature?: number | null; /** * Top K sampling. */ top_k?: number | null; /** * Top P sampling. */ top_p?: number | null; /** * Whether to stream the response. */ stream?: boolean | null; /** * System prompt. */ system?: string | null; /** * Metadata to attach to the request. */ metadata?: Record | null; /** * Custom text sequences that will cause the model to stop generating. */ stop_sequences?: string[] | null; /** * Configuration for enabling Claude's extended thinking. */ thinking?: Thinking | null; /** * Controls which (if any) tool is called by the model. */ tool_choice?: ToolChoice | null; /** * Definitions of tools that the model may use. */ tools?: Tool[] | null; } /** * Messages API - Anthropic-compatible endpoint * @see https://docs.aimlapi.com/api-reference/messages */ export declare class Messages { private readonly _client; constructor(_client: AIMLAPIClient); /** * Create a message using the Anthropic-compatible API. * * @example * ```typescript * const response = await client.messages.create({ * model: "claude-3-5-sonnet-20241022", * messages: [ * { role: "user", content: "Hello, Claude!" } * ], * max_tokens: 1024, * }); * console.log(response.content[0].text); * ``` */ create(params: MessagesParams): Promise; /** * Create a streaming message response. * * @example * ```typescript * const stream = await client.messages.create({ * model: "claude-3-5-sonnet-20241022", * messages: [{ role: "user", content: "Write a story" }], * stream: true, * }); * * for await (const event of stream) { * if (event.type === "content_block_delta") { * process.stdout.write(event.delta.delta.text); * } * } * ``` */ createStream(params: MessagesParams): Promise>; private convertOpenAIStreamToAnthropic; } //# sourceMappingURL=messages.d.ts.map