POST /v1/chat/completions
Route chat completion requests to OpenRouter with optional Nightly memory, Policies guardrails, and Adaption fine-tuning support. Compatible with the OpenAI SDK.
Authentication
Bearer token with your API key. Format: Bearer YOUR_ASYMMETRIC_API_KEY
Request Body
The model to use (e.g., openai/gpt-4o-mini, anthropic/claude-3-sonnet, etc.)
Array of message objects with role and content fields
Whether to stream the response
Sampling temperature (0-2)
Maximum tokens to generate
Nightly (Memory) Parameters
Enable agent memory. Format: ["memory_group", "user_goal"]
memory_group: Unique identifier for the memory pool
user_goal: Description to help curate relevant memories
Policies (Guardrails) Parameters
Natural language policy to check outputs against. If provided, outputs are filtered in real-time.
For streaming: how often to check guardrails (every N chunks)
For streaming: number of recent chunks to check together
Adaption (Fine-tuning) Parameters
Memory call count threshold to trigger training queue
Minimum memories needed before triggering training
Name of the LoRA adapter to use or create
Set to true to use your finetuned LoRA adapter for inference
Response
Returns an OpenAI-compatible chat completion response.
Unique identifier for the completion
Array of completion choices
Example
from openai import OpenAI
client = OpenAI(
base_url="https://rkdune--symmetry.modal.run/v1/",
api_key="YOUR_ASYMMETRIC_API_KEY",
)
# Basic completion with memory and guardrails
completion = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
extra_body={
"nightly": ["my_agent", "A helpful assistant"],
"guardrail_policy": "Flag any inappropriate content"
}
)
print(completion.choices[0].message.content)
Errors
| Status | Description |
|---|
| 400 | Guardrail violation detected or invalid parameters |
| 401 | Invalid API key |
| 402 | Insufficient credits |