mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-06 22:00:40 +08:00
Merge pull request #1744 from irfansofyana/openrouter-support
Openrouter support
This commit is contained in:
@ -278,6 +278,22 @@ key = "..." # your Codestral api key
|
|||||||
|
|
||||||
(you can obtain a Codestral key from [here](https://console.mistral.ai/codestral))
|
(you can obtain a Codestral key from [here](https://console.mistral.ai/codestral))
|
||||||
|
|
||||||
|
### Openrouter
|
||||||
|
|
||||||
|
To use model from Openrouter, for example, set:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[config] # in configuration.toml
|
||||||
|
model="openrouter/anthropic/claude-3.7-sonnet"
|
||||||
|
fallback_models=["openrouter/deepseek/deepseek-chat"]
|
||||||
|
custom_model_max_tokens=20000
|
||||||
|
|
||||||
|
[openrouter] # in .secrets.toml or passed an environment variable openrouter__key
|
||||||
|
key = "..." # your openrouter api key
|
||||||
|
```
|
||||||
|
|
||||||
|
(you can obtain an Openrouter API key from [here](https://openrouter.ai/settings/keys))
|
||||||
|
|
||||||
### Custom models
|
### Custom models
|
||||||
|
|
||||||
If the relevant model doesn't appear [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py), you can still use it as a custom model:
|
If the relevant model doesn't appear [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py), you can still use it as a custom model:
|
||||||
|
@ -118,6 +118,18 @@ class LiteLLMAIHandler(BaseAiHandler):
|
|||||||
litellm.api_base = self.api_base
|
litellm.api_base = self.api_base
|
||||||
openai.api_base = self.api_base
|
openai.api_base = self.api_base
|
||||||
|
|
||||||
|
# Support for Openrouter models
|
||||||
|
if get_settings().get("OPENROUTER.KEY", None):
|
||||||
|
openrouter_api_key = get_settings().get("OPENROUTER.KEY", None)
|
||||||
|
os.environ["OPENROUTER_API_KEY"] = openrouter_api_key
|
||||||
|
litellm.api_key = openrouter_api_key
|
||||||
|
openai.api_key = openrouter_api_key
|
||||||
|
|
||||||
|
openrouter_api_base = get_settings().get("OPENROUTER.API_BASE", "https://openrouter.ai/api/v1")
|
||||||
|
os.environ["OPENROUTER_API_BASE"] = openrouter_api_base
|
||||||
|
self.api_base = openrouter_api_base
|
||||||
|
litellm.api_base = openrouter_api_base
|
||||||
|
|
||||||
# Models that only use user meessage
|
# Models that only use user meessage
|
||||||
self.user_message_only_models = USER_MESSAGE_ONLY_MODELS
|
self.user_message_only_models = USER_MESSAGE_ONLY_MODELS
|
||||||
|
|
||||||
|
@ -107,4 +107,8 @@ key = ""
|
|||||||
client_id = "" # Your Azure AD application client ID
|
client_id = "" # Your Azure AD application client ID
|
||||||
client_secret = "" # Your Azure AD application client secret
|
client_secret = "" # Your Azure AD application client secret
|
||||||
tenant_id = "" # Your Azure AD tenant ID
|
tenant_id = "" # Your Azure AD tenant ID
|
||||||
api_base = "" # Your Azure OpenAI service base URL (e.g., https://openai.xyz.com/)
|
api_base = "" # Your Azure OpenAI service base URL (e.g., https://openai.xyz.com/)
|
||||||
|
|
||||||
|
[openrouter]
|
||||||
|
key = ""
|
||||||
|
api_base = ""
|
Reference in New Issue
Block a user