Skip to main content

Module openai

Module openai 

Source
Expand description

OpenAI API compatibility types

This module defines types that match the OpenAI API specification for chat completions, completions, and model management.

Structs§

ChatChoice
Chat choice
ChatCompletionsRequest
Chat completions request (OpenAI compatible)
ChatCompletionsResponse
Chat completions response
ChatFunction
Function schema for tools[].function and legacy functions[].
ChatFunctionCall
Function call payload. OpenAI serializes arguments as a JSON string.
ChatMessage
Chat message
ChatTool
Tool definition in OpenAI chat-completion requests.
ChatToolCall
Assistant tool call in OpenAI responses and historical conversation input.
CompletionChoice
Completion choice
CompletionsRequest
Legacy completions request
CompletionsResponse
Completions response
EmbeddingData
Single embedding result
EmbeddingItem
A single embedding input item — text or image.
EmbeddingUsage
Token usage for embeddings
EmbeddingsRequest
Embeddings request (OpenAI-compatible, extended for images)
EmbeddingsResponse
Embeddings response (OpenAI-compatible)
ModelInfo
Model information
ModelListResponse
Model list response
ModelPermission
Model permission
OpenAiError
OpenAI API error
OpenAiErrorDetail
OpenAI error detail
OpenAiJsonSchema
OpenAiResponseFormat
OpenAI-compatible response format specifier.
SpeechRequest
TTS speech request (OpenAI compatible /v1/audio/speech)
SseEvent
Server-sent event for streaming
StreamOptions
OpenAI streaming options.
ToolChoiceFunction
TranscriptionResponse
Transcription response (OpenAI-compatible)
Usage
Token usage information

Enums§

CompletionPrompt
Legacy completions prompt. Kept as a parsed enum so the HTTP layer can return an OpenAI-shaped field error instead of a generic JSON rejection.
EmbeddingInput
Polymorphic embedding input. Supports: single string, array of strings, single object, array of objects.
FunctionCallChoice
Legacy function_call accepts a simple mode string or a named function.
MessageRole
Message roles
OpenAiErrorType
OpenAI error types
ToolChoice
OpenAI tool_choice accepts either a simple mode string or a specific function-tool selector object.