1 Provider routing🔗ℹ

(provider id base-url env-vars requires-key? kind) -> provider?

  id           : symbol?

  base-url     : string?

  env-vars     : (listof string?)

  requires-key? : boolean?

  kind         : (or/c 'openai 'anthropic)

Built-in providers: openai, anthropic, gemini, mistral, deepseek, ollama. A model string always names its provider explicitly, and a bare model name is rejected — a typo should fail loudly, never silently route to some default vendor.

(parse-model model #:provider provider-id) -> (values provider? string?)

(provider-ref id) -> provider?

(provider-names) -> (listof symbol?)

(add-provider! p) -> void?

(provider-api-key p explicit-key) -> (or/c string? #f)

API keys resolve in one order: the explicit #:api-key argument, then the provider’s environment variables in declared order, then failure for providers that require a key. Keyless local providers (ollama) resolve to #f.

Register any other OpenAI-compatible endpoint by adding one provider; the chat path is shared:

(add-provider!
 (provider 'groq "https://api.groq.com/openai/v1"
           '("GROQ_API_KEY") #t 'openai))
(ask "groq/llama-3.1-8b-instant" "Say hi.")