Documentation Index
Fetch the complete documentation index at: https://narev.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Endpoint
POST /api/applications/{application_id}/v1/chat/completions
Authentication
Include your Narev API key in theAuthorization header:
Setup
- Python
- TypeScript
- cURL
Request parameters
Required
Array of message objects, each with a
role (system, user, or assistant) and content string.Optional
Parameter support varies by model. Check your model’s documentation to confirm which parameters it accepts.
Model identifier with gateway prefix (for example,
openai:gpt-4). If omitted, Narev uses the A/B test’s production variant.Sampling temperature between
0 and 2. Higher values produce more random output.Nucleus sampling parameter between
0 and 1. Lower values make output more focused.Limits sampling to the K most likely next tokens.
Maximum number of tokens to generate in the response.
Penalizes tokens based on their frequency in the text so far. Range:
-2.0 to 2.0.Penalizes tokens that have already appeared in the text so far. Range:
-2.0 to 2.0.Penalizes repeated tokens. Typical range:
0.0 to 2.0.Minimum probability threshold for token selection. Range:
0 to 1.Random seed for deterministic generation.
When
true, returns log probabilities for each output token.Number of top log probabilities to return. Range:
0 to 20. Requires logprobs: true.Controls the format of the response. Pass
{"type": "json_object"} to enable JSON mode.Up to four sequences at which the API stops generating further tokens.
When
true, Narev streams the response as server-sent events (SSE).Custom metadata for tracking and automatic quality evaluation.
| Field | Type | Description |
|---|---|---|
expected_output | string | Expected response text for automatic quality scoring |
Model identifiers
Models use a{gateway}:{model_name} format:
| Gateway | Example |
|---|---|
openai | openai:gpt-4 |
anthropic | anthropic:claude-3-opus-20240229 |
openrouter | openrouter:meta-llama/llama-3.1-70b-instruct |
vertex | vertex:gemini-pro |
bedrock | bedrock:amazon.titan-text-express-v1 |
portkey | portkey:gpt-4 |
helicone | helicone:gpt-4 |
Request examples
Basic request
With system prompt
With generation parameters
With JSON response format
Streaming
With quality evaluation
Response format
Non-streaming
Streaming
Narev sends each token as a server-sent event (SSE) with adata: prefix:
Error responses
All errors return a JSON object with anerror field:
| Status | Code | Description |
|---|---|---|
400 | bad_request | Invalid request format or parameters |
400 | model_required | Model is required when no production variant is set |
401 | invalid_api_key | Invalid or missing API key |
402 | insufficient_credits | Insufficient credits to complete the request |
404 | application_not_found | A/B test ID not found |
500 | internal_error | Internal server error |