/** * OpenAI client types. */ import type { BaseIntegrationClient } from "../../types.js"; import type { SupportsApiRequest } from "../base/index.js"; /** * OpenAI client for AI model interactions. * * Provides the generic apiRequest() method for any OpenAI API endpoint. * Use this to interact with OpenAI's chat completions, embeddings, and other endpoints. * * @example * ```typescript * import { z } from 'zod'; * * // Declare in api(): integrations: { ai: openai(INTEGRATION_ID) } * // In run(), access via ctx.integrations.ai * * // Define request and response schemas * const ChatCompletionRequestSchema = z.object({ * model: z.string(), * messages: z.array(z.object({ * role: z.string(), * content: z.string(), * })), * }); * * const CompletionSchema = z.object({ * id: z.string(), * choices: z.array(z.object({ * message: z.object({ * role: z.string(), * content: z.string(), * }), * })), * }); * * // Make a chat completion request * const completion = await ctx.integrations.ai.apiRequest( * { * method: 'POST', * path: '/chat/completions', * body: { * model: 'gpt-4', * messages: [{ role: 'user', content: 'Hello!' }], * }, * }, * { * body: ChatCompletionRequestSchema, * response: CompletionSchema, * } * ); * * ``` */ export interface OpenAIClient extends BaseIntegrationClient, SupportsApiRequest { // apiRequest() method inherited from SupportsApiRequest }