openai_compatible

package
v1.4.430 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderMap = map[string]ProviderConfig{
	"AIML": {
		Name:                "AIML",
		BaseURL:             "https://api.aimlapi.com/v1",
		ImplementsResponses: false,
	},
	"Cerebras": {
		Name:                "Cerebras",
		BaseURL:             "https://api.cerebras.ai/v1",
		ImplementsResponses: false,
	},
	"DeepSeek": {
		Name:                "DeepSeek",
		BaseURL:             "https://api.deepseek.com",
		ImplementsResponses: false,
	},
	"GitHub": {
		Name:                "GitHub",
		BaseURL:             "https://models.github.ai/inference",
		ModelsURL:           "https://models.github.ai/catalog",
		ImplementsResponses: false,
	},
	"Infermatic": {
		Name:                "Infermatic",
		BaseURL:             "https://api.totalgpt.ai/v1",
		ImplementsResponses: false,
	},
	"GrokAI": {
		Name:                "GrokAI",
		BaseURL:             "https://api.x.ai/v1",
		ImplementsResponses: true,
	},
	"Groq": {
		Name:                "Groq",
		BaseURL:             "https://api.groq.com/openai/v1",
		ImplementsResponses: false,
	},
	"Langdock": {
		Name:                "Langdock",
		BaseURL:             "https://api.langdock.com/openai/{{REGION=us}}/v1",
		ImplementsResponses: false,
	},
	"LiteLLM": {
		Name:                "LiteLLM",
		BaseURL:             "http://localhost:4000",
		ImplementsResponses: false,
	},
	"MiniMax": {
		Name:                "MiniMax",
		BaseURL:             "https://api.minimax.io/v1",
		ModelsURL:           "static:minimax",
		ImplementsResponses: false,
	},
	"Mistral": {
		Name:                "Mistral",
		BaseURL:             "https://api.mistral.ai/v1",
		ImplementsResponses: false,
	},
	"Novita AI": {
		Name:                "Novita AI",
		BaseURL:             "https://api.novita.ai/openai/v1",
		ImplementsResponses: false,
	},
	"OpenRouter": {
		Name:                "OpenRouter",
		BaseURL:             "https://openrouter.ai/api/v1",
		ImplementsResponses: false,
	},
	"SiliconCloud": {
		Name:                "SiliconCloud",
		BaseURL:             "https://api.siliconflow.cn/v1",
		ImplementsResponses: false,
	},
	"Together": {
		Name:                "Together",
		BaseURL:             "https://api.together.xyz/v1",
		ImplementsResponses: false,
	},
	"Venice AI": {
		Name:                "Venice AI",
		BaseURL:             "https://api.venice.ai/api/v1",
		ImplementsResponses: false,
	},
	"Z AI": {
		Name:                "Z AI",
		BaseURL:             "https://api.z.ai/api/paas/v4",
		ImplementsResponses: false,
	},
	"Abacus": {
		Name:                "Abacus",
		BaseURL:             "https://routellm.abacus.ai/v1/",
		ModelsURL:           "static:abacus",
		ImplementsResponses: false,
	},
	"Mammouth": {
		Name:                "Mammouth",
		BaseURL:             "https://api.mammouth.ai/v1",
		ImplementsResponses: false,
	},
}

ProviderMap is a map of provider name to ProviderConfig for O(1) lookup

Functions

This section is empty.

Types

type Client

type Client struct {
	*openai.Client
	// contains filtered or unexported fields
}

Client is the common structure for all OpenAI-compatible providers

func CreateClient

func CreateClient(providerName string) (*Client, bool)

CreateClient creates a new client for a provider by name

func NewClient

func NewClient(providerConfig ProviderConfig) *Client

NewClient creates a new OpenAI-compatible client for the specified provider

func (*Client) DirectlyGetModels added in v1.4.245

func (c *Client) DirectlyGetModels(ctx context.Context) ([]string, error)

DirectlyGetModels is used to fetch models directly from the API when the standard OpenAI SDK method fails due to a nonstandard format.

func (*Client) ListModels added in v1.4.245

func (c *Client) ListModels() ([]string, error)

ListModels overrides the default ListModels to handle different response formats

func (*Client) NeedsRawMode added in v1.4.390

func (c *Client) NeedsRawMode(modelName string) bool

NeedsRawMode overrides the parent implementation to handle provider-specific raw mode requirements

type ProviderConfig

type ProviderConfig struct {
	Name                string
	BaseURL             string
	ModelsURL           string // Optional: Custom endpoint for listing models (if different from BaseURL/models)
	ImplementsResponses bool   // Whether the provider supports OpenAI's new Responses API
}

ProviderConfig defines the configuration for an OpenAI-compatible API provider

func GetProviderByName

func GetProviderByName(name string) (ProviderConfig, bool)

GetProviderByName returns the provider configuration for a given name with O(1) lookup

Jump to

Keyboard shortcuts

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