Documentation
¶
Overview ¶
Package openai implements the llm.Provider contract against the OpenAI Chat Completions API. Stdlib-only.
Translation notes:
- llm.ContentBlock is folded into OpenAI's flatter message shape: an assistant turn collapses text blocks into one message.content and tool_use blocks into message.tool_calls; a user turn's tool_result blocks become separate role:"tool" messages.
- Stop reasons are normalized to the engine's vocabulary ("stop"→"end_turn", "tool_calls"→"tool_use", "length"→"max_tokens").
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Provider)
Option configures a Provider.
func WithAPIKey ¶
WithAPIKey overrides the key picked up from OPENAI_API_KEY.
func WithBaseURL ¶
WithBaseURL points the client at a custom origin (Azure, proxies, tests).
func WithChatPath ¶
WithChatPath overrides the chat completions path (default "/v1/chat/completions").
func WithCompat ¶
func WithCompat() Option
WithCompat marks this provider as targeting a non-OpenAI endpoint. Disables json_schema response_format (not supported by most compat endpoints). stream_options is kept enabled since most compat endpoints support it.
func WithHTTPClient ¶
WithHTTPClient swaps the underlying http.Client.
func WithNoStreamOptions ¶
func WithNoStreamOptions() Option
WithNoStreamOptions disables stream_options (for endpoints like Gemini that reject it).