API Reference
OpenAI-compatible API endpoints for applications and routers.
Using Narev's live API endpoints is optional for running A/B tests. You can import traces from your existing provider and run experiments without changing your production code. See Integrations to connect your current observability or gateway provider.
Endpoints
Narev provides two types of API endpoints that follow the OpenAI v1 chat completions format, making it easy to integrate with existing OpenAI-compatible clients.
-
/api/applications/{application_id}/v1/chat/completions- use when you want to add requests directly to the A/B test. Allows control over which model, system prompt, and parameters to use. -
/api/router/{router_id}/v1/chat/completions- use when you want to dynamically route requests to different A/B tests based on rules defined in the Narev UI
Key Differences
| Feature | /applications | /router |
|---|---|---|
| Model Selection | Specify in request | Configured in UI routing rules |
| System Prompt | Override via request | Uses routed A/B test's settings |
| Parameters | Override via request | Uses routed A/B test's settings |
| Routing Logic | Not applicable | Define filters and conditions in UI |
Authentication
Both endpoints use API key authentication. Include your API key in the request header:
Authorization: Bearer YOUR_API_KEYYou can generate API keys in the Narev dashboard under Settings → API Keys.
OpenAI SDK Compatibility
Both endpoints are fully compatible with the OpenAI SDK. Simply replace the base URL and API key:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_NAREV_API_KEY",
base_url="https://narev.ai/api/applications/{application_id}/v1"
)
response = client.chat.completions.create(
model="openai:gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)Quick Links
- Applications API - Full control via API requests
- Router API - Dynamic routing based on content