Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5577ae8
feat: Add comprehensive OpenAI base URL configuration support
orestesgarcia Sep 4, 2025
39f753a
fix: Address PR review feedback for OpenAI base URL configuration
orestesgarcia Sep 4, 2025
e06fbc6
Update python/src/agents/agent_provider_config.py
orestesgarcia Sep 4, 2025
6db9b19
Update python/src/agents/base_agent.py
orestesgarcia Sep 4, 2025
c4cf1c7
Update python/src/agents/agent_provider_config.py
orestesgarcia Sep 4, 2025
c462c18
Update python/src/agents/agent_provider_config.py
orestesgarcia Sep 4, 2025
1091e1b
docs: Add OpenAI base URL configuration documentation
orestesgarcia Sep 4, 2025
f7fcf77
feat: Centralize OpenAI client configuration across all services
orestesgarcia Sep 4, 2025
a4e1689
docs: Update documentation to reflect centralized OpenAI configuration
orestesgarcia Sep 4, 2025
9da7379
Update docs/docs/api-reference.mdx
orestesgarcia Sep 4, 2025
8b71633
Update docs/docs/rag.mdx
orestesgarcia Sep 4, 2025
54d29a3
Update python/src/agents/agent_provider_config.py
orestesgarcia Sep 4, 2025
efb5f20
Update python/src/server/services/llm_provider_service.py
orestesgarcia Sep 4, 2025
2f26bf6
fix: Improve error logging in LLM provider service
orestesgarcia Sep 4, 2025
1a770ce
feat: Improve error handling and observability in base agent
orestesgarcia Sep 4, 2025
3c53fde
feat: Improve private host detection for HTTP URL warnings
orestesgarcia Sep 4, 2025
58a9e13
feat: Add configurable timeouts and retries to OpenAI clients
orestesgarcia Sep 4, 2025
8604252
Update docs/docs/rag.mdx
orestesgarcia Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions archon-ui-main/src/components/settings/RAGSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface RAGSettingsProps {
USE_RERANKING: boolean;
LLM_PROVIDER?: string;
LLM_BASE_URL?: string;
OPENAI_BASE_URL?: string;
EMBEDDING_MODEL?: string;
// Crawling Performance Settings
CRAWL_BATCH_SIZE?: number;
Expand Down Expand Up @@ -85,6 +86,20 @@ export const RAGSettings = ({
/>
</div>
)}
{ragSettings.LLM_PROVIDER === 'openai' && (
<div>
<Input
label="OpenAI Base URL (optional)"
value={ragSettings.OPENAI_BASE_URL || ''}
onChange={e => setRagSettings({
...ragSettings,
OPENAI_BASE_URL: e.target.value
})}
placeholder="https://api.openai.com/v1"
accentColor="green"
/>
</div>
)}
<div className="flex items-end">
<Button
variant="outline"
Expand Down
11 changes: 6 additions & 5 deletions docs/docs/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@ Retrieve all RAG configuration settings including LLM provider options.
"USE_RERANKING": "true",
"LLM_PROVIDER": "openai",
"LLM_BASE_URL": null,
"OPENAI_BASE_URL": "http://localhost:8000/v1",
"EMBEDDING_MODEL": null
}
}
Expand All @@ -1475,11 +1476,11 @@ Retrieve all RAG configuration settings including LLM provider options.

| Setting | Type | Description |
|---------|------|-------------|
| `LLM_PROVIDER` | string | Provider choice: `openai`, `ollama`, `google` |
| `LLM_BASE_URL` | string | Custom base URL (required for Ollama) |
| `EMBEDDING_MODEL` | string | Override default embedding model |
| `MODEL_CHOICE` | string | Chat model for summaries and contextual embeddings |

| `LLM_PROVIDER` | string | Provider choice: `openai`, `ollama`, `google` |
| `LLM_BASE_URL` | string | Custom base URL (required for Ollama) |
| `OPENAI_BASE_URL` | string | Custom OpenAI endpoint for proxies (LiteLLM, Azure OpenAI) — applies system-wide |
| `EMBEDDING_MODEL` | string | Override default embedding model |
| `MODEL_CHOICE` | string | Chat model for summaries and contextual embeddings |
## 💬 Agent Chat API

<Admonition type="warning" title="Integration Note">
Expand Down
47 changes: 47 additions & 0 deletions docs/docs/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,57 @@ Configure in **Settings → RAG Settings → LLM Provider**

<Admonition type="tip" title="Provider Setup">
- **API Keys**: Add provider-specific keys in Settings → API Keys
- **Custom Base URLs**: Configure custom endpoints for OpenAI-compatible proxies
- **Ollama**: Requires local installation and custom base URL
- **Models**: Each provider has different model naming conventions
</Admonition>

#### OpenAI Base URL Configuration

For advanced use cases, you can configure a custom OpenAI base URL to route **all OpenAI API requests** through:
- **LiteLLM proxy** for multi-provider access
- **Azure OpenAI** endpoints
- **Corporate proxies** or custom gateways
- **Local OpenAI-compatible servers**

<Admonition type="info" title="Centralized Configuration">
The `OPENAI_BASE_URL` setting applies consistently across **all services**:
- PydanticAI agents (RAG, document processing, task management)
- LLM provider service (embeddings, contextual processing)
- Background tasks and batch operations

This ensures consistent proxy routing for all OpenAI API usage throughout the system.
</Admonition>

<Tabs>
<TabItem value="ui" label="UI Configuration" default>

1. Navigate to **Settings → RAG Settings**
2. Select **OpenAI** as your LLM Provider
3. Enter your custom **OpenAI Base URL** (optional)
4. Examples:
- LiteLLM: `http://localhost:8000/v1`
- Azure OpenAI: `https://your-resource.openai.azure.com/openai/deployments/your-deployment`
- Custom proxy: `https://api.yourcompany.com/openai/v1`

</TabItem>
<TabItem value="env" label="Environment Variables">

```bash
# Optional - Custom OpenAI endpoint
OPENAI_BASE_URL=http://localhost:8000/v1

# Required when using custom base URL
OPENAI_API_KEY=your-api-key-here
```

<Admonition type="warning" title="Security Requirements">
When using a custom `OPENAI_BASE_URL`, an API key must be provided for security reasons. This prevents accidental traffic leaks to public endpoints when a proxy is explicitly configured.
</Admonition>

</TabItem>
</Tabs>

### Socket.IO Configuration

Archon uses Socket.IO for all real-time features. The default configuration works out of the box:
Expand Down
65 changes: 64 additions & 1 deletion docs/docs/rag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,66 @@ USE_RERANKING=true
LLM_PROVIDER=openai
MODEL_CHOICE=gpt-4o-mini
EMBEDDING_MODEL=text-embedding-3-small
# Pros: Best accuracy, reliable API

# Optional: Custom OpenAI endpoint
OPENAI_BASE_URL=https://api.openai.com/v1

# Pros: Best accuracy, reliable API, proxy support
# Cons: Cost per query
```

#### OpenAI Proxy Configuration

Configure custom endpoints for advanced routing scenarios. These settings apply to **all OpenAI API usage** including RAG queries, embeddings, and background processing:

<Tabs>
<TabItem value="litellm" label="LiteLLM Proxy" default>

```bash
# LiteLLM proxy for multi-provider access
LLM_PROVIDER=openai
OPENAI_BASE_URL=http://localhost:8000/v1
MODEL_CHOICE=gpt-4o-mini # Route through LiteLLM
OPENAI_API_KEY=your-litellm-key

# Benefits:
# - Multi-provider routing (OpenAI, Anthropic, etc.)
# - Cost tracking and rate limiting
# - Centralized API management
```

**LiteLLM Setup:**
```bash
# Install LiteLLM
pip install litellm[proxy]

# Start proxy server
litellm --port 8000 --config litellm_config.yaml
```

</TabItem>
<TabItem value="azure" label="Azure OpenAI">


</TabItem>
<TabItem value="corporate" label="Corporate Proxy">

```bash
# Corporate gateway/proxy
LLM_PROVIDER=openai
OPENAI_BASE_URL=https://api.yourcompany.com/openai/v1
MODEL_CHOICE=gpt-4o-mini
OPENAI_API_KEY=your-internal-key

# Benefits:
# - Centralized billing and monitoring
# - Security and compliance enforcement
# - Custom authentication and authorization
```

</TabItem>
</Tabs>

### Google Gemini
```bash
LLM_PROVIDER=google
Expand Down Expand Up @@ -368,6 +424,13 @@ EMBEDDING_MODEL=nomic-embed-text
3. Use caching more aggressively
4. Consider switching to local models (Ollama)

### API Key Management
- **Separate Keys**: Use different API keys for proxy vs direct OpenAI access
- **Key Rotation**: Regularly rotate API keys, especially for proxy endpoints
- **Environment Variables**: Never hardcode keys in configuration files
- **Least Privilege**: Proxy keys should have minimal required permissions
- **No Secrets in Logs**: Disable logging of Authorization headers and redact API keys in all logs.

## 🎯 Best Practices

### Content Optimization
Expand Down
Loading