Documentation
¶
Overview ¶
Package deepinfra provides DeepInfra integration for the LLM gateway.
Index ¶
- Variables
- func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
- type Provider
- func (p *Provider) CreateImage(ctx context.Context, req *core.ImageGenerationRequest) (*core.ImageGenerationResponse, error)
- func (p *Provider) CreateImageEdit(ctx context.Context, req *core.ImageEditRequest) (*core.ImageGenerationResponse, error)
- func (p *Provider) CreateSpeech(ctx context.Context, req *core.AudioSpeechRequest) (*core.AudioResponse, error)
- func (p *Provider) CreateTranscription(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
- func (p *Provider) CreateTranslation(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
- func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)
- func (p *Provider) Responses(ctx context.Context, req *core.ResponsesRequest) (*core.ResponsesResponse, error)
- func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
var Registration = providers.Registration{ Type: "deepinfra", New: New, Discovery: providers.DiscoveryConfig{ DefaultBaseURL: defaultBaseURL, }, }
Registration provides factory registration for the DeepInfra provider.
Functions ¶
func New ¶
func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
New creates a new DeepInfra provider.
Types ¶
type Provider ¶
type Provider struct {
*openai.ChatCompatible
*openai.BatchSurface
*openai.FileSurface
}
Provider implements DeepInfra's OpenAI-compatible API. Chat completions, embeddings, and passthrough go through the shared chat-centric adapter; Responses is forwarded to DeepInfra's native /responses endpoint, except requests setting "text", which are translated through chat completions; image generation and edits, speech, transcription, translation, files, and batches use the matching OpenAI routes. DeepInfra's Responses endpoint is stateless, so no response lifecycle (retrieve, cancel, delete) is exposed: the gateway replays previous_response_id history itself when it has a response store.
func (*Provider) CreateImage ¶
func (p *Provider) CreateImage(ctx context.Context, req *core.ImageGenerationRequest) (*core.ImageGenerationResponse, error)
CreateImage generates images through DeepInfra's /images/generations endpoint.
func (*Provider) CreateImageEdit ¶
func (p *Provider) CreateImageEdit(ctx context.Context, req *core.ImageEditRequest) (*core.ImageGenerationResponse, error)
CreateImageEdit edits images through DeepInfra's /images/edits endpoint.
func (*Provider) CreateSpeech ¶
func (p *Provider) CreateSpeech(ctx context.Context, req *core.AudioSpeechRequest) (*core.AudioResponse, error)
CreateSpeech synthesizes speech through DeepInfra's /audio/speech endpoint. DeepInfra answers WAV when response_format is omitted, so the OpenAI default ("mp3") is sent explicitly.
func (*Provider) CreateTranscription ¶
func (p *Provider) CreateTranscription(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
CreateTranscription transcribes audio through DeepInfra's /audio/transcriptions endpoint.
func (*Provider) CreateTranslation ¶
func (p *Provider) CreateTranslation(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
CreateTranslation translates audio into English through DeepInfra's /audio/translations endpoint.
func (*Provider) ListModels ¶
ListModels returns DeepInfra's model catalog with the context, pricing, and kind tags its OpenAI-compatible listing carries. Models whose tags name only kinds the gateway cannot serve (video generation) are skipped so the catalog never advertises a model that can only fail.
func (*Provider) Responses ¶
func (p *Provider) Responses(ctx context.Context, req *core.ResponsesRequest) (*core.ResponsesResponse, error)
Responses forwards a Responses API request to DeepInfra's native endpoint, or through chat completions when the native endpoint cannot serve it (see needsChatTranslation).
func (*Provider) StreamResponses ¶
func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
StreamResponses streams a Responses API request the same way Responses routes it.