Skip to content

Conversation

@mik-tf
Copy link
Contributor

@mik-tf mik-tf commented Dec 20, 2025

Summary

  • Added support for OpenRouter API alongside existing Google Gemini integration, enabling users to access a wide variety of AI models through a unified interface.
  • Closes Add Other AI API Support #8

Key Features

🔄 Multi-Provider Support

  • Provider Selection: Users can choose between Google Gemini and OpenRouter
  • Seamless Switching: Clean provider switching with proper API key management
  • API Key Separation: Prevents cross-contamination between different provider keys

🤖 OpenRouter Integration

  • Comprehensive Model List: 12 popular models including Claude, GPT, Grok, and specialized models
  • Custom Model Support: "Custom Model" option for any OpenRouter model name
  • Enhanced Tool Calling: Robust JSON parsing strategies for reliable function execution

🛠️ Technical Improvements

  • Multi-Strategy Parsing: 4 fallback parsing approaches for maximum compatibility
  • Optimized Prompts: Provider-specific system prompts for better model performance
  • Error Recovery: Graceful handling of API responses and quota limits

🎨 UI Enhancements

  • Smart Model Selection: Dropdown for Gemini, dropdown + custom input for OpenRouter
  • Provider-Specific Fields: Dynamic API key labeling and model lists
  • Intuitive Workflow: Clear separation between preset and custom model options

Files Changed

  • grid-agent-gui/app.go - Backend provider switching and settings management
  • grid-agent-gui/frontend/src/components/Settings.svelte - UI for provider/model selection
  • grid-agent/agent/pkg/llm/openrouter.go - OpenRouter provider implementation
  • grid-agent/agent/go.mod - Added OpenAI client dependency

Testing

  • ✅ Backend compilation successful
  • ✅ Frontend build passes
  • ✅ Tool calling verified (tfcmd contract operations work correctly)
  • ✅ Provider switching maintains API key integrity
  • ✅ Custom model input functional

Usage

Users can now select OpenRouter as their AI provider and choose from popular models like Claude, Grok, and GPT variants, with full tool calling capabilities for ThreeFold Grid operations.

Notes

  • Tested with free models and it works well but obviously we can reach free quote limits.

@mik-tf
Copy link
Contributor Author

mik-tf commented Dec 21, 2025

Converting to draft and will make another PR without conflict.

@mik-tf mik-tf marked this pull request as draft December 21, 2025 17:00
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.

Add Other AI API Support

2 participants