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 SelectionSpecify in requestConfigured in UI routing rules
System PromptOverride via requestUses routed A/B test's settings
ParametersOverride via requestUses routed A/B test's settings
Routing LogicNot applicableDefine filters and conditions in UI

Authentication

Both endpoints use API key authentication. Include your API key in the request header:

Authorization: Bearer YOUR_API_KEY

You 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!"}]
)