Skip to content

Enable custom LLM gateway configurations via configurable model constants#97

Open
maximilianmueller-tchibo wants to merge 2 commits intoperplexityai:mainfrom
maximilianmueller-tchibo:main
Open

Enable custom LLM gateway configurations via configurable model constants#97
maximilianmueller-tchibo wants to merge 2 commits intoperplexityai:mainfrom
maximilianmueller-tchibo:main

Conversation

@maximilianmueller-tchibo
Copy link
Copy Markdown

This PR refactors hardcoded model names into configurable environment variables with sensible defaults. This change enables the Perplexity MCP server to work seamlessly with custom LLM gateway deployments where model identifiers may differ from the standard Perplexity API naming conventions.

Changes:

  • Added configurable model environment variables:
    • SONAR_PRO_MODEL (default: "sonar-pro")
    • SONAR_REASONING_MODEL (default: "sonar-reasoning-pro")
    • SONAR_DEEP_RESEARCH_MODEL (default: "sonar-deep-research")
  • Updated all references from hardcoded strings to use these constants

Why this is needed:
When deploying with a custom LLM gateway (e.g., using LiteLLM Proxy, Kong, or other middleware), model names may be mapped to different identifiers. For example:

  • Gateway mapping: perplexity-sonar-pro → actual Perplexity API sonar-pro
  • Internal naming: Your organization may use standardized model names across providers

Without this change, users would need to fork and modify the source code to use alternative model identifiers. Now they can simply set environment variables:

SONAR_PRO_MODEL=perplexity-sonar-pro
SONAR_REASONING_MODEL=perplexity-sonar-reasoning-pro
SONAR_DEEP_RESEARCH_MODEL=perplexity-sonar-deep-research

This maintains full backward compatibility while adding flexibility for enterprise deployments and custom gateway configurations.

Usage Example:
"environment": {
"PERPLEXITY_API_KEY": "your-custom-key", #e.g. litellm sk-xxx
"PERPLEXITY_BASE_URL": "https://your-companies-llm-proxy",
"SONAR_PRO_MODEL": "perplexity-sonar-pro",
"SONAR_REASONING_MODEL": "perplexity-sonar-reasoning-pro",
"SONAR_DEEP_RESEARCH_MODEL": "perplexity-sonar-deep-research"
},

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.

2 participants