Skip to content

Commit 09cf354

Browse files
authored
Merge pull request #110 from ktpedre/cerebras
Add support for Cerebras to litellm_caller
2 parents 3939b1f + 1ace821 commit 09cf354

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ OPENAI_API_KEY=sk-pro
3434
ANTHROPIC_API_KEY=your_anthropic_api_key_here
3535
GOOGLE_API_KEY=your_google_api_key_here
3636
OPENROUTER_API_KEY=sk-or
37+
CEREBRAS_API_KEY=your_cerebras_api_key_here
3738

3839

3940
# Banner system configuration

backend/modules/llm/litellm_caller.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def _get_litellm_model_name(self, model_name: str) -> str:
5757
return f"anthropic/{model_id}"
5858
elif "google" in model_config.model_url:
5959
return f"google/{model_id}"
60+
elif "cerebras" in model_config.model_url:
61+
return f"cerebras/{model_id}"
6062
else:
6163
# For custom endpoints, use the model_id directly
6264
return model_id
@@ -95,10 +97,12 @@ def _get_model_kwargs(self, model_name: str, temperature: Optional[float] = None
9597
os.environ["ANTHROPIC_API_KEY"] = api_key
9698
elif "google" in model_config.model_url:
9799
os.environ["GOOGLE_API_KEY"] = api_key
100+
elif "cerebras" in model_config.model_url:
101+
os.environ["CEREBRAS_API_KEY"] = api_key
98102

99103
# Set custom API base for non-standard endpoints
100104
if hasattr(model_config, 'model_url') and model_config.model_url:
101-
if not any(provider in model_config.model_url for provider in ["openrouter", "api.openai.com", "api.anthropic.com"]):
105+
if not any(provider in model_config.model_url for provider in ["openrouter", "api.openai.com", "api.anthropic.com", "api.cerebras.ai"]):
102106
kwargs["api_base"] = model_config.model_url
103107

104108
# Handle extra headers with environment variable expansion
@@ -339,4 +343,4 @@ def _format_rag_metadata(self, metadata) -> str:
339343
summary_parts.append(f" • ... and {remaining} more document(s)")
340344

341345
summary_parts.append(f" **Retrieval Method:** {metadata.retrieval_method}")
342-
return "\n".join(summary_parts)
346+
return "\n".join(summary_parts)

config/overrides/llmconfig.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ models:
3838
model_url: "https://api.openai.com/v1/chat/completions"
3939
model_name: "gpt-4.1-nano"
4040
api_key: "${OPENAI_API_KEY}"
41-
compliance_level: "External"
41+
compliance_level: "External"
42+
cerebras-gpt-oss-120b:
43+
model_url: "https://api.cerebras.ai/v1"
44+
model_name: "gpt-oss-120b"
45+
api_key: "${CEREBRAS_API_KEY}"
46+
compliance_level: "External"

0 commit comments

Comments
 (0)