Skip to content

feat: OpenRouter LLM integration (#95)#657

Open
faisalnugroho wants to merge 1 commit into
Spectral-Finance:mainfrom
faisalnugroho:feat/openrouter-integration
Open

feat: OpenRouter LLM integration (#95)#657
faisalnugroho wants to merge 1 commit into
Spectral-Finance:mainfrom
faisalnugroho:feat/openrouter-integration

Conversation

@faisalnugroho
Copy link
Copy Markdown

Summary

Implements OpenRouter integration for the Lux framework, providing access to 200+ LLM models through a single unified API.

Features

  • OpenRouter API Client: Full implementation compatible with OpenAI chat completions format
  • Model Discovery: Browse available models with filtering
  • Cost Estimation: Budget planning with get_model_cost and estimate_cost
  • Provider Preferences: Route requests to specific providers
  • Fallback Support: Automatic failover to alternative models
  • Cost Tracking: Built-in telemetry for monitoring API costs
  • Error Handling: Proper handling of rate limits, auth errors, and transport failures

Acceptance Criteria

  • Implement OpenRouter API client
  • Add support for multiple models
  • Create unified interface matching other providers
  • Implement proper error handling and retries
  • Add cost tracking and reporting
  • Include comprehensive documentation
  • Add integration tests

Usage

Basic usage with OpenRouter:

Lux.LLM.OpenRouter.call("Hello!", [], %{model: "openai/gpt-4o"})

With provider preferences:

Lux.LLM.OpenRouter.call("Hello!", [], %{
  model: "anthropic/claude-3.5-sonnet",
  provider_preferences: %{allow_fallbacks: true}
})

List available models:

{:ok, models} = Lux.LLM.OpenRouter.list_models(filter: "anthropic")

Estimate cost:

cost = Lux.LLM.OpenRouter.estimate_cost("openai/gpt-4o", 1000, 500)

Closes #95

- Implement OpenRouter API client with full OpenAI compatibility
- Add model listing and cost estimation capabilities
- Support provider preferences, fallbacks, and route configuration
- Include comprehensive documentation and usage examples
- Add telemetry-based cost tracking

Closes Spectral-Finance#95
@faisalnugroho
Copy link
Copy Markdown
Author

Hi! Just following up on this PR. Let me know if there are any changes needed or if you have any questions about the implementation.

@faisalnugroho
Copy link
Copy Markdown
Author

Hi! Just following up on this PR. OpenRouter LLM integration. All checks pass — would appreciate your review when you get a chance. Thanks!

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.

OpenRouter Integration $500

1 participant