openai

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package openai implements chat.Client with the OpenAI Responses API; it also works with endpoints compatible with the Responses API (such as DeepSeek).

Index

Constants

View Source
const (

	// ModelGPT6Luna is the default model.
	ModelGPT6Luna = "gpt-6-luna"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyProvider

type APIKeyProvider func(ctx context.Context) (string, error)

APIKeyProvider resolves the API key dynamically, for short-lived tokens.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Responses API of the OpenAI SDK.

func New

func New(cfg Config) *Client

New creates a Responses API chat.Client.

func (*Client) Info

func (c *Client) Info() chat.ModelInfo

Info returns the model info.

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, req chat.Request) iter.Seq[chat.Event]

Stream sends a streaming request.

type Config

type Config struct {
	APIKey          string
	APIKeyProvider  APIKeyProvider
	BaseURL         string
	Model           string
	MaxInputTokens  int
	MaxOutputTokens int
	Timeout         time.Duration
	MaxRetries      int
	Headers         map[string]string
	HTTPClient      *http.Client

	// Reasoning means the model is a reasoning model: requests ask for reasoning.summary and for encrypted reasoning content,
	// so history can be replayed statelessly. Regular models reject these parameters, so it is off by default.
	Reasoning bool
	// ImageGeneration enables the built-in image_generation tool so the model can generate images in its replies.
	// Images in assistant messages in history (including those generated by other models) are replayed as input_image in a user message regardless of this setting.
	ImageGeneration bool
	// DisableStoreParams means the endpoint does not recognize the store / include parameters (such as DeepSeek), so they are not sent.
	DisableStoreParams bool
	// TextOnly means the endpoint accepts no media input.
	TextOnly bool
	// NoStructuredOutput means the endpoint does not support the json_schema output format; the format requirements go into the system prompt instead.
	NoStructuredOutput bool
	// HTTPHooks are debugging hooks at the raw HTTP layer.
	HTTPHooks chat.HTTPHooks
}

Config configures the Responses API Client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL