Custom Endpoints
You can use the OpenAI provider with any OpenAI-compatible API endpoint. This is useful for connecting to local model servers, third-party providers, or self-hosted models that expose an OpenAI-compatible chat completions API.
Configuration
Set the Endpoint option on the OpenAI provider to point to your custom API:
- ASP.NET
- Node.js
- Java
Program.cs
builder.Services.AddRevealAI()
.AddOpenAI(options =>
{
options.ApiKey = "your-api-key";
options.Endpoint = "https://your-custom-endpoint.com/v1";
options.Model = "your-model-name";
});
Or using appsettings.json:
appsettings.json
{
"RevealAI": {
"OpenAI": {
"ApiKey": "your-api-key",
"Endpoint": "https://your-custom-endpoint.com/v1",
"Model": "your-model-name"
}
}
}
server.js
const aiSettings = {
openai: {
ApiKey: 'your-api-key',
Endpoint: 'https://your-custom-endpoint.com/v1',
Model: 'your-model-name'
}
};
revealAI.withOptions({
defaultProvider: 'openai',
settings: aiSettings
});
Application.java
Map<String, Object> aiSettings = Map.of(
"openai", Map.of(
"ApiKey", "your-api-key",
"Endpoint", "https://your-custom-endpoint.com/v1",
"Model", "your-model-name"));
Common Use Cases
Local Model Servers
Tools like Ollama, LM Studio, and vLLM expose OpenAI-compatible APIs that can be used directly:
- ASP.NET
- Node.js
- Java
// Ollama example
builder.Services.AddRevealAI()
.AddOpenAI(options =>
{
options.ApiKey = "ollama"; // Ollama doesn't require a real key
options.Endpoint = "http://localhost:11434/v1";
options.Model = "llama3";
});
// Ollama example
const aiSettings = {
openai: {
ApiKey: 'ollama', // Ollama doesn't require a real key
Endpoint: 'http://localhost:11434/v1',
Model: 'llama3'
}
};
// Ollama example
Map<String, Object> aiSettings = Map.of(
"openai", Map.of(
"ApiKey", "ollama", // Ollama doesn't require a real key
"Endpoint", "http://localhost:11434/v1",
"Model", "llama3"));
Third-Party Providers
Many AI providers offer OpenAI-compatible endpoints:
- ASP.NET
- Node.js
- Java
builder.Services.AddRevealAI()
.AddOpenAI(options =>
{
options.ApiKey = "your-provider-api-key";
options.Endpoint = "https://api.provider.com/v1";
options.Model = "provider-model-name";
});
const aiSettings = {
openai: {
ApiKey: 'your-provider-api-key',
Endpoint: 'https://api.provider.com/v1',
Model: 'provider-model-name'
}
};
Map<String, Object> aiSettings = Map.of(
"openai", Map.of(
"ApiKey", "your-provider-api-key",
"Endpoint", "https://api.provider.com/v1",
"Model", "provider-model-name"));
Limitations
When using custom endpoints, be aware of:
- The endpoint must support the OpenAI Chat Completions API format
- Token usage reporting depends on the endpoint's compatibility
- Reasoning model detection is based on model name patterns (o1, o3, o4, gpt-5) and may not apply to custom models
- Some advanced features may not be supported by all custom endpoints
Custom Providers
If your endpoint doesn't follow the OpenAI-compatible API format, consider building a custom provider instead.