v0.10.5

Custom Endpoints

Last updated


How to point the router at a self-hosted or third-party OpenAI-compatible endpoint, or at Cloudflare Workers AI.

Self-hosted and third-party compatible endpoints


  1. // Explicit instance name; Name() reports lmstudio@qwen3-30b
  2. agent, err := router.New(router.Config{
  3. Name: "compat[lmstudio]@qwen3-30b",
  4. BaseURL: "http://127.0.0.1:1234/v1",
  5. APIKey: "not-needed",
  6. })
  7. // An unknown prefix falls through to compat and keeps its prefix in Name()
  8. agent, err = router.New(router.Config{
  9. Name: "groq@llama-3.3-70b",
  10. BaseURL: "https://api.groq.com/openai/v1",
  11. APIKey: os.Getenv("GROQ_API_KEY"),
  12. })

Cloudflare Workers AI


  1. agent, err := router.New(router.Config{
  2. Name: "cloudflare@@cf/meta/llama-3.3-70b-instruct-fp8-fast",
  3. APIKey: os.Getenv("CLOUDFLARE_API_KEY"),
  4. AccountID: os.Getenv("CLOUDFLARE_ACCOUNT_ID"),
  5. GatewayID: os.Getenv("CLOUDFLARE_GATEWAY_ID"),
  6. })

Model listings filter on the Workers AI task name rather than model-ID markers, so ModelFilter{STTOnly: true} selects the Automatic Speech Recognition task.

中文