Documentation
¶
Overview ¶
Package xiaomi resolves Xiaomi MiMo API base URLs for pay-as-you-go and Token Plan.
Index ¶
- Constants
- func AppendKeyMismatchHint(err error, providerID, secret string) error
- func ApplyPlatformMetadata(id, displayName, description string, ctx, maxOut int, ...) (string, string, int, int, float64, float64, json.RawMessage)
- func FetchOpenAIModelsJSON(ctx context.Context, baseURL, apiKey string) ([]json.RawMessage, error)
- func FetchPlatformModelsIndex(ctx context.Context, catalogURL string) (map[string]PlatformModel, error)
- func IsRetryableHTTPStatus(status int) bool
- func KeyMismatchHint(billing Billing, secret string) string
- func NativeModelID(id string) string
- func PlatformModelsURLFromEnv(env map[string]string) string
- func ProbeOpenAIModels(ctx context.Context, baseURL, apiKey string) error
- func ResolveAnthropicBase(billing Billing, region Region) (string, error)
- func ResolveOpenAIBase(billing Billing, region Region, override string) (string, error)
- func ResolveOpenAIBasePreferRegion(billing Billing, region Region, override string) (string, error)
- func SetMimoRequestAuth(req *http.Request, apiKey string)
- type Billing
- type PlatformModel
- type Region
Constants ¶
const ( PayAsYouGoOpenAIBase = "https://api.xiaomimimo.com/v1" PayAsYouGoAnthropicBase = "https://api.xiaomimimo.com/anthropic" TokenPlanCNOpenAIBase = "https://token-plan-cn.xiaomimimo.com/v1" TokenPlanCNAnthropicBase = "https://token-plan-cn.xiaomimimo.com/anthropic" TokenPlanSGPOpenAIBase = "https://token-plan-sgp.xiaomimimo.com/v1" TokenPlanSGPAnthropicBase = "https://token-plan-sgp.xiaomimimo.com/anthropic" TokenPlanAMSOpenAIBase = "https://token-plan-ams.xiaomimimo.com/v1" TokenPlanAMSAnthropicBase = "https://token-plan-ams.xiaomimimo.com/anthropic" )
const DefaultPlatformModelsURL = "https://platform.xiaomimimo.com/api/v1/models"
DefaultPlatformModelsURL is the public MiMo platform catalog (context, pricing, names). Inference GET {base}/models only returns id/object/owned_by.
const ProviderPayAsYouGo = "xiaomi_mimo_payg"
ProviderPayAsYouGo is the registry / setup gateway id for pay-as-you-go.
const ProviderTokenPlan = "xiaomi_mimo_token_plan"
ProviderTokenPlan is the registry / setup gateway id for Token Plan.
Variables ¶
This section is empty.
Functions ¶
func AppendKeyMismatchHint ¶
AppendKeyMismatchHint adds a billing/key-shape hint to probe or setup errors (never blocks save).
func ApplyPlatformMetadata ¶
func ApplyPlatformMetadata( id, displayName, description string, ctx, maxOut int, inPrice, outPrice float64, inferenceRaw json.RawMessage, platform map[string]PlatformModel, ) (string, string, int, int, float64, float64, json.RawMessage)
ApplyPlatformMetadata fills empty live fields from platform catalog; stores platform JSON as metadata when matched.
func FetchOpenAIModelsJSON ¶
FetchOpenAIModelsJSON GETs /models and returns raw model objects from the OpenAI list response.
func FetchPlatformModelsIndex ¶
func FetchPlatformModelsIndex(ctx context.Context, catalogURL string) (map[string]PlatformModel, error)
FetchPlatformModelsIndex GETs the platform catalog and indexes by native model id.
func IsRetryableHTTPStatus ¶
IsRetryableHTTPStatus reports whether chat may retry via Anthropic compatibility.
func KeyMismatchHint ¶
KeyMismatchHint returns a user-facing hint when key shape may not match billing (never blocks save).
func NativeModelID ¶
NativeModelID strips vendor prefix (xiaomi/mimo-v2.5 → mimo-v2.5).
func PlatformModelsURLFromEnv ¶
PlatformModelsURLFromEnv returns override URL for tests, else DefaultPlatformModelsURL.
func ProbeOpenAIModels ¶
ProbeOpenAIModels GETs {baseURL}/models using api-key auth, then Bearer on 401.
func ResolveAnthropicBase ¶
ResolveAnthropicBase returns the Anthropic-compatible base URL (no /v1 suffix).
func ResolveOpenAIBase ¶
ResolveOpenAIBase returns the OpenAI-compatible base URL (with /v1 suffix).
func ResolveOpenAIBasePreferRegion ¶
ResolveOpenAIBasePreferRegion returns the OpenAI base URL. For Token Plan, a valid region wins over a stale persisted override (e.g. user switched cn → sgp but base URL was not cleared).
func SetMimoRequestAuth ¶
SetMimoRequestAuth applies MiMo-preferred auth (api-key header).
Types ¶
type Billing ¶
type Billing string
Billing identifies pay-as-you-go vs Token Plan products (independent keys and hosts).
func BillingForProvider ¶
BillingForProvider maps registry provider ids to billing mode.
type PlatformModel ¶
type PlatformModel struct {
ID string
Name string
Description string
ContextLength int
MaxOutputLength int
InputPricePer1M float64
OutputPricePer1M float64
Raw json.RawMessage
}
PlatformModel is one row from the platform catalog API.
type Region ¶
type Region string
Region is a Token Plan cluster (required for token_plan billing).
func NormalizeRegion ¶
NormalizeRegion parses a region id (cn, sgp, ams).