API Documentation
OpenAI-compatible chat/completions interface with persistent context, automatic learning options, scoped prompt resolution, and multi-provider key forwarding.
Chat Completions
POST
/api/v1/chat/completionsProxy for OpenAI and Anthropic Chat APIs with automatic history prepending and system prompt injection. Supports GPT-4, Claude, and other models.
Scope:
chat:writeRequest
bash
curl -X POST "https://www.mnexium.com/api/v1/chat/completions" \
-H "x-mnexium-key: $MNX_KEY" \
-H "Content-Type: application/json" \
-H "x-openai-key: $OPENAI_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{ "role": "user", "content": "I just switched to VS Code. Can you update my setup recommendations?" }
],
"mnx": {
"subject_id": "user_123",
"chat_id": "550e8400-e29b-41d4-a716-446655440000",
"log": true,
"learn": true,
"recall": true,
"history": true
}
}'mnx Parameters
subject_idstring
User/subject identifier for memory and history.
chat_idstring
Conversation ID (UUID recommended) for history grouping.
logboolean
Save to chat history. Default: true
learnboolean | 'force'
Memory extraction: false (never), true (LLM decides), "force" (always). Default: true
historyboolean
Prepend chat history. Default: true
system_promptstring | boolean
Prompt ID, true (auto-resolve), or false (skip). Default: true
memory_policystring | boolean
Memory policy ID, false (skip), or omitted/true (auto-resolve). Default: true
Response
json
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1702847400,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Great choice! Since you work with Rust and Python, I'd recommend installing rust-analyzer and...",
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 10, "completion_tokens": 12, "total_tokens": 22 }
}Response headers include
X-Mnx-Chat-Id and X-Mnx-Subject-Id▶Show streaming exampleHide streaming example
Set "stream": true to receive Server-Sent Events (SSE).
Request
bash
curl -X POST "https://www.mnexium.com/api/v1/chat/completions" \
-H "x-mnexium-key: $MNX_KEY" \
-H "Content-Type: application/json" \
-H "x-openai-key: $OPENAI_KEY" \
-d '{ "model": "gpt-4o-mini", "messages": [{"role":"user","content":"What were we discussing last time?"}], "mnx": { "subject_id": "user_123", "history": true }, "stream": true }'Response (SSE)
data: {"choices":[{"delta":{"role":"assistant"},"index":0}]}
data: {"choices":[{"delta":{"content":"Last"},"index":0}]}
data: {"choices":[{"delta":{"content":" time"},"index":0}]}
data: {"choices":[{"delta":{"content":" we"},"index":0}]}
data: {"choices":[{"delta":{"content":" talked"},"index":0}]}
data: {"choices":[{"delta":{"content":" about"},"index":0}]}
data: {"choices":[{"delta":{"content":" your Rust project..."},"index":0}]}
data: {"choices":[{"delta":{},"finish_reason":"stop","index":0}]}
data: [DONE]Parse each data: line as JSON. Concatenate delta.content values to build the response.