Skip to content

Conversation

@mamoreau-devolutions
Copy link
Contributor

Adds an experimental AI Gateway feature that provides a unified proxy for multiple AI provider APIs through Devolutions Gateway. This enables centralized API key management, consistent authentication, and simplified access to various AI services from a single endpoint.

The gateway supports seven providers with OpenAI-compatible and provider-specific endpoints, featuring transparent proxying, SSE streaming support, and flexible configuration through both JSON config and environment variables.

Supported providers:

  • Mistral AI (cloud API)
  • OpenAI (cloud API)
  • Anthropic Claude (cloud API with custom message format)
  • OpenRouter (unified multi-provider API)
  • Azure OpenAI (deployment-based Azure service)
  • Ollama (local, OpenAI-compatible, optional auth)
  • LM Studio (local, OpenAI-compatible, optional auth)

Key features:

  • Builder pattern for provider configuration with flexible auth methods
  • Generic proxy function supporting Bearer tokens and custom headers
  • Server-Sent Events (SSE) streaming for real-time completions
  • Gateway-level API key authentication (optional)
  • Environment variable overrides for all provider endpoints and keys
  • Configurable request timeout (default: 300s)
  • Transparent request/response proxying

Architecture:

  • Provider-agnostic design with ProviderConfigBuilder
  • Support for Bearer auth (OpenAI, Mistral, OpenRouter)
  • Support for custom header auth (Anthropic x-api-key, Azure api-key)
  • Automatic injection of provider-specific headers
  • Full SSE streaming support across all providers

Configuration follows existing patterns with JSON schema support and environment variable overrides (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.). Local providers (Ollama, LM Studio) default to localhost endpoints and have optional authentication.

Requires enable_unstable: true in debug configuration.

Adds an experimental AI Gateway feature that provides a unified proxy for
multiple AI provider APIs through Devolutions Gateway. This enables centralized
API key management, consistent authentication, and simplified access to various
AI services from a single endpoint.

The gateway supports seven providers with OpenAI-compatible and provider-specific
endpoints, featuring transparent proxying, SSE streaming support, and flexible
configuration through both JSON config and environment variables.

Supported providers:
- Mistral AI (cloud API)
- OpenAI (cloud API)
- Anthropic Claude (cloud API with custom message format)
- OpenRouter (unified multi-provider API)
- Azure OpenAI (deployment-based Azure service)
- Ollama (local, OpenAI-compatible, optional auth)
- LM Studio (local, OpenAI-compatible, optional auth)

Key features:
- Builder pattern for provider configuration with flexible auth methods
- Generic proxy function supporting Bearer tokens and custom headers
- Server-Sent Events (SSE) streaming for real-time completions
- Gateway-level API key authentication (optional)
- Environment variable overrides for all provider endpoints and keys
- Configurable request timeout (default: 300s)
- Transparent request/response proxying

Architecture:
- Provider-agnostic design with ProviderConfigBuilder
- Support for Bearer auth (OpenAI, Mistral, OpenRouter)
- Support for custom header auth (Anthropic x-api-key, Azure api-key)
- Automatic injection of provider-specific headers
- Full SSE streaming support across all providers

Configuration follows existing patterns with JSON schema support and environment
variable overrides (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.). Local providers
(Ollama, LM Studio) default to localhost endpoints and have optional authentication.

Requires enable_unstable: true in debug configuration.

Issue: DGW-XXX
@github-actions
Copy link

Let maintainers know that an action is required on their side

  • Add the label release-required Please cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module) when you request a maintainer to cut a new release (Devolutions Gateway, Devolutions Agent, Jetsocat, PowerShell module)

  • Add the label release-blocker Follow-up is required before cutting a new release if a follow-up is required before cutting a new release

  • Add the label publish-required Please publish libraries (`Devolutions.Gateway.Utils`, OpenAPI clients, etc) when you request a maintainer to publish libraries (Devolutions.Gateway.Utils, OpenAPI clients, etc.)

  • Add the label publish-blocker Follow-up is required before publishing libraries if a follow-up is required before publishing libraries

Copy link
Contributor

Copilot AI commented Nov 27, 2025

@CBenoit I've opened a new pull request, #1589, to work on those changes. Once the pull request is ready, I'll request review from you.

Comment on lines +56 to +62
/// Default HTTP client with a longer timeout suitable for AI requests.
fn create_client(timeout: Duration) -> reqwest::Client {
reqwest::Client::builder()
.timeout(timeout)
.build()
.expect("parameters known to be valid only")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I think it’s better to reuse the client instead of creating a new one for each request. We could use some sort of caching.

@CBenoit
Copy link
Member

CBenoit commented Nov 27, 2025

@copilot Implement some smoke tests in the testsuite crate.

Copilot AI mentioned this pull request Nov 27, 2025
8 tasks
Copy link
Contributor

Copilot AI commented Nov 27, 2025

@CBenoit I've opened a new pull request, #1590, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Member

@CBenoit CBenoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CBenoit CBenoit merged commit b11f050 into master Nov 27, 2025
40 checks passed
@CBenoit CBenoit deleted the experimental-ai-gateway branch November 27, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants