openai_compatible

package
v1.4.511 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 9 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

Index

Constants

This section is empty.

Variables

View Source
var ProviderMap = map[string]ProviderConfig{
	"Abacus": {
		Name:                "Abacus",
		BaseURL:             "https://routellm.abacus.ai/v1/",
		ModelsURL:           "static:abacus",
		ImplementsResponses: false,
	},
	"AIML": {
		Name:                "AIML",
		BaseURL:             "https://api.aimlapi.com/v1",
		ImplementsResponses: false,
	},
	"Aliyun DashScope": {
		Name:                "Aliyun DashScope",
		BaseURL:             "https://dashscope.aliyuncs.com/compatible-mode/v1",
		ImplementsResponses: false,
	},
	"Apple Foundation Models": {
		Name:                "Apple Foundation Models",
		BaseURL:             "http://localhost:1976/v1",
		ImplementsResponses: false,
		ApiKeyOptional:      true,
	},
	"API Route": {
		Name:                "API Route",
		BaseURL:             "https://global.api-route.com/v1",
		ImplementsResponses: false,
	},
	"ByteDance Ark": {
		Name:                "ByteDance Ark",
		BaseURL:             "https://ark.cn-beijing.volces.com/api/v3",
		ImplementsResponses: false,
	},
	"Cerebras": {
		Name:                "Cerebras",
		BaseURL:             "https://api.cerebras.ai/v1",
		ImplementsResponses: false,
	},
	"Cheaper Inference": {
		Name:                "Cheaper Inference",
		BaseURL:             "https://api.cheaperinference.com/v1",
		ImplementsResponses: false,
	},
	"DeepSeek": {
		Name:                "DeepSeek",
		BaseURL:             "https://api.deepseek.com",
		ImplementsResponses: false,
	},
	"Eden AI": {
		Name:                "Eden AI",
		BaseURL:             "https://api.edenai.run/v3",
		ImplementsResponses: false,
	},
	"FuturMix": {
		Name:                "FuturMix",
		BaseURL:             "https://futurmix.ai/v1",
		ImplementsResponses: false,
	},
	"Infermatic": {
		Name:                "Infermatic",
		BaseURL:             "https://api.totalgpt.ai/v1",
		ImplementsResponses: false,
	},
	"GrokAI": {
		Name:                "GrokAI",
		BaseURL:             "https://api.x.ai/v1",
		ImplementsResponses: true,

		WebSearchToolName: "web_search",
		EnableXSearch:     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,
	},
	"llmman": {
		Name:                "llmman",
		BaseURL:             "http://localhost:17434/v1",
		ImplementsResponses: false,
	},
	"Mammouth": {
		Name:                "Mammouth",
		BaseURL:             "https://api.mammouth.ai/v1",
		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,
	},
	"OpenCode Go": {
		Name:                "OpenCode Go",
		BaseURL:             "https://opencode.ai/zen/go/v1",
		ImplementsResponses: false,
		SessionHeader:       openCodeSessionHeader,
		UserAgent:           "fabric",
	},
	"OpenCode Zen": {
		Name:                "OpenCode Zen",
		BaseURL:             "https://opencode.ai/zen/v1",
		ImplementsResponses: false,
		SessionHeader:       openCodeSessionHeader,
		UserAgent:           "fabric",
	},
	"OpenRouter": {
		Name:                "OpenRouter",
		BaseURL:             "https://openrouter.ai/api/v1",
		ImplementsResponses: false,
	},
	"OrcaRouter": {
		Name:                "OrcaRouter",
		BaseURL:             "https://api.orcarouter.ai/v1",
		ImplementsResponses: false,
	},
	"Pzero": {
		Name:                "Pzero",
		BaseURL:             "https://api.pzero.studio/v1",
		ImplementsResponses: false,
	},
	"Requesty": {
		Name:                "Requesty",
		BaseURL:             "https://router.requesty.ai/v1",
		ImplementsResponses: false,
	},
	"SiliconCloud": {
		Name:                "SiliconCloud",
		BaseURL:             "https://api.siliconflow.cn/v1",
		ImplementsResponses: false,
	},
	"Synthorai": {
		Name:                "Synthorai",
		BaseURL:             "https://synthorai.io/v1",
		ImplementsResponses: false,
	},
	"Together": {
		Name:                "Together",
		BaseURL:             "https://api.together.xyz/v1",
		ImplementsResponses: false,
	},
	"TrustedRouter": {
		Name:                "TrustedRouter",
		BaseURL:             "https://api.trustedrouter.com/v1",
		ImplementsResponses: false,
	},
	"Venice AI": {
		Name:                "Venice AI",
		BaseURL:             "https://api.venice.ai/api/v1",
		ImplementsResponses: false,
	},
	"Y-API": {
		Name:                "Y-API",
		BaseURL:             "https://api.y-api.bestvirtualgoods.com/v1",
		ImplementsResponses: false,
	},
	"Z AI": {
		Name:                "Z AI",
		BaseURL:             "https://api.z.ai/api/paas/v4",
		ImplementsResponses: false,
	},
	"Zhipu AI": {
		Name:                "Zhipu AI",
		BaseURL:             "https://open.bigmodel.cn/api/paas/v4",
		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) IsConfigured added in v1.4.498

func (c *Client) IsConfigured() bool

IsConfigured reports whether the vendor is ready to use. A provider with an optional API key has no setting that can fail, so it would always count as configured. For those, require the base URL in the environment, which fabric -S writes when the user selects the provider. Ollama uses the same rule.

func (*Client) ListModels added in v1.4.245

func (c *Client) ListModels(ctx context.Context) ([]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
	// WebSearchToolName overrides the default "web_search_preview" tool name
	// emitted on the Responses API when Search is enabled. Leave empty to keep
	// the OpenAI default. xAI, for example, requires "web_search".
	WebSearchToolName string
	// EnableXSearch, when true, also appends an xAI "x_search" tool entry
	// alongside the web search tool when Search is enabled. Non-xAI
	// providers should leave this false.
	EnableXSearch bool
	// SessionHeader, when non-empty, is the request header used to carry a
	// stable per-conversation session ID. OpenCode, for example, expects
	// "x-opencode-session" so it can optimize routing and prompt caching.
	SessionHeader string
	// UserAgent, when non-empty, overrides the SDK's default User-Agent
	// header. Providers that ask clients to identify themselves (e.g.
	// OpenCode) should set this.
	UserAgent string
	// ApiKeyOptional makes the API key not required at setup. Local servers
	// such as Apple's fm serve accept requests without a key.
	ApiKeyOptional bool
}

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