Skip to content

Openrouter migration#4

Merged
RaghavSood merged 7 commits intomainfrom
openrouter-migration
Feb 24, 2026
Merged

Openrouter migration#4
RaghavSood merged 7 commits intomainfrom
openrouter-migration

Conversation

@neavra
Copy link
Contributor

@neavra neavra commented Feb 23, 2026

Migrate AI client from Anthropic to OpenRouter + per-request model selection

Summary

  • Migrate AI provider from Anthropic to OpenRouter, enabling access to any model (Claude, Gemini, Llama, etc.) through a single API
  • Add per-request model selection — frontend can optionally send a model field to override the default model per message
  • Update env config from ANTHROPIC_* to AI_* env vars with sensible defaults (only AI_API_KEY is required)

Changes

  • internal/ai/anthropic/client.gointernal/ai/client.go — rewrite client for OpenRouter-compatible API (headers, model fallback)
  • internal/config/config.go — new AIConfig with AI_API_KEY, AI_MODEL, AI_BASE_URL, etc.
  • cmd/server/main.go — wire up new config fields
  • internal/service/agent/types.go — add optional Model field to SendMessageRequest
  • internal/service/agent/agent.go — pass req.Model into AI request (empty string falls back to configured default)
  • internal/service/agent/{tools,prompt,memory}.go — update import paths from ai/anthropicai
  • .env.example, deploy/*.yaml, README.md — updated env vars and docs

Migration

Existing deployments need to replace env vars:
ANTHROPIC_API_KEY → AI_API_KEY (OpenRouter key)
ANTHROPIC_MODEL → AI_MODEL (has default)

Tested

  • Default model (no model field) → 200, uses configured default
  • Model override ("model": "google/gemini-2.5-pro") → 200, routes to Gemini
  • Invalid model ("model": "fakeprovider/nonsense") → 500, clear validation error

Copy link

@4others 4others left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

valueFrom:
secretKeyRef:
name: anthropic
name: ai-provider
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change anthropic token value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be the openRouter API key. Which is a different key from anthropic, it should start with sk-or.... instead of sk-ant

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@realpaaao Hi, please create https://openrouter.ai/ tokens for dev and prod and share with me

@RaghavSood RaghavSood merged commit 6089204 into main Feb 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants