API Documentation
OpenAI-compatible chat threads + SDUI SDK. Authenticate with an SDK API key from the cockpit.
Authentication
All public endpoints use Bearer authentication. Generate a key at /sdk-keys in the cockpit. Keys are scoped:
- •
chat— threads, messages, runs, knowledge, tools, profiles, identity, usage - •
view— SDUI view definitions + data - •
action— SDUI view actions - •
admin— SDK key management
Authorization: Bearer oag_xxxxxxxxxxxxxxxxxxxxxxxxx
Chat Completions scope: chat
Drop-in OpenAI-compatible endpoint. Point the official openai SDK (or LangChain, Vercel AI SDK, etc.) at https://omra.pro/v1 with your OAG key as api_key — chooses any model exposed by the gateway via the model field.
/v1/chat/completionsEach call materializes a throwaway thread (source: "completions") so the run goes through the same multimodal / RAG / guardrails pipeline as the Threads API. system messages are extracted into orchestrator instructions, other roles preserved as-is.
curl https://omra.pro/v1/chat/completions \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Hello!"}
]
}'
# Python — official openai SDK works unchanged
from openai import OpenAI
client = OpenAI(api_key="oag_...", base_url="https://omra.pro/v1")
resp = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Привет"}],
)
print(resp.choices[0].message.content)
Multimodal: pass content as an array with image_url parts (HTTPS or data: URIs). Vision routing happens automatically.
Streaming: set stream: true; emits standard OpenAI chat.completion.chunk SSE frames, terminated by data: [DONE]. Add stream_options: {"include_usage": true} for a final usage frame.
/v1/modelsList models available to your company (system catalog + per-company overrides). Use the returned id as the model field in completions.
curl https://omra.pro/v1/models \
-H "Authorization: Bearer $OAG_KEY"
Available Models snapshot: 2026-05-18
Pass any id below as the model field. The live source of truth is always GET /v1/models — call it from your client instead of hardcoding this list.
Cross-provider fallback (Claude, Llama, Qwen, DeepSeek, Mistral via OpenRouter).
GitHub Copilot upstream — Claude and GPT routed through Copilot's API.
Total: 72 models as of the snapshot above. Models named *-chat-latest are recommended for general use; aliases like gpt-5.4 follow OpenAI's promotion schedule. Direct-Anthropic claude-* slugs are temporarily disabled — use or-claude-sonnet-4 / or-claude-opus-4 / or-claude-3-5-haiku via OpenRouter for now.
Chat API scope: chat
OpenAI Assistants-compatible threads, messages, runs. — stateful alternative to Chat Completions when you want messages and runs to persist across calls.
/v1/threadscurl -X POST https://omra.pro/v1/threads \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{"metadata": {"user": "alice"}}'
/v1/threads/{thread_id}/v1/threads/{thread_id}/messagescurl -X POST https://omra.pro/v1/threads/$TID/messages \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{"role": "user", "content": "Analyze my Ozon sales for last week"}'
/v1/threads/{thread_id}/messages/bulkBatch-add multiple messages in one request.
/v1/threads/{thread_id}/messages?limit=20&after=…/v1/threads/{thread_id}/runsExecute a model run on the thread. Non-streaming returns a single RunResponse; stream: true opens an SSE channel.
- •
model— required. Any slug fromGET /v1/models. - •
instructions— extra system-prompt layer for this run. - •
stream— boolean (default false). When true, response is SSE. - •
enable_multimodal— boolean (default true). Routesimage_urlparts through vision + OCR before the main model. - •
profile_ids— list of SDK profile UUIDs to compose (system prompts, KB / tool bindings, model defaults). Multiple profiles merge — system prompts concatenate, KB and tool lists union. - •
mentioned_file_ids— list of workspace file IDs the user referenced in the thread (so the orchestrator can hand them to tools that need explicit file access). Ownership is validated server-side. - •
use_kb— override the profile's KB toggle (trueto force RAG on,falseto force off). - •
use_tools— same idea for tool calling. - •
tool_choice—"auto"(default) /"none"/"required"/{"type":"function","function":{"name":"save_contact"}}to force a specific tool.
curl -X POST https://omra.pro/v1/threads/$TID/runs \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"instructions": "Be concise.",
"stream": false,
"enable_multimodal": true,
"profile_ids": ["a4d3...sales-agent"],
"mentioned_file_ids": ["7c2f...invoice.pdf"],
"use_kb": true,
"use_tools": true,
"tool_choice": "auto"
}'
- •
id,thread_id,model,status,content - •
usage—{prompt_tokens, completion_tokens, total_tokens} - •
tool_calls— list of{name, args, result}emitted by the run (empty if no tools fired). - •
applied_rules,latency_ms
# SSE frames when stream=true
data: {"delta": "Hello", "model": "gpt-4o"}
data: {"delta": " world", "model": "gpt-4o"}
data: {"done": true, "usage": {"prompt_tokens": 42, "completion_tokens": 7, "total_tokens": 49}, "latency_ms": 812}
data: [DONE]
Knowledge Base scope: chat
RAG collections scoped to your company. Upload PDF/TXT/MD/DOCX/XLSX — indexing runs asynchronously, attach collection IDs to a profile via knowledge_base_ids.
/v1/knowledgeList active collections.
/v1/knowledgecurl -X POST https://omra.pro/v1/knowledge \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Sales playbook", "description": "Internal scripts"}'
/v1/knowledge/{collection_id}Soft delete (deactivates the collection; documents preserved for audit).
/v1/knowledge/{collection_id}/documentsList up to 500 most recent documents with status (pending / ready / failed).
/v1/knowledge/{collection_id}/documentsmultipart/form-dataReturns 202 Accepted. Allowed MIME: application/pdf, text/plain, text/markdown, DOCX, XLSX, legacy DOC/XLS. Optional folder_path field for grouping.
curl -X POST https://omra.pro/v1/knowledge/$CID/documents \
-H "Authorization: Bearer $OAG_KEY" \
-F "file=@playbook.pdf" \
-F "folder_path=/onboarding"
/v1/knowledge/{collection_id}/documents/{document_id}Agent Tools scope: chat
Register company-scoped function tools the agent can call during a run (e.g. save_contact posting back to your CRM). Attach by name via a profile's allowed_tool_names.
/v1/tools/v1/tools/{tool_id}/v1/toolsIdempotent by name — re-posting an existing active tool returns it unchanged.
curl -X POST https://omra.pro/v1/tools \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "save_contact",
"description": "Persist visitor contact in CRM",
"json_schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"phone": {"type": "string"}
},
"required": ["phone"]
},
"python_code": "def run(name, phone):\n return httpx.post(WEBHOOK, json={...}).json()"
}'
/v1/tools/{tool_id}Partial update of name / description / schema / code / is_active.
/v1/tools/{tool_id}Soft delete — historical run logs that reference the tool stay intact.
SDK Profiles scope: chat
Reusable presets that bundle a model, system prompt, allowed tools and knowledge bases. One profile per company can be marked is_default.
/v1/profiles?full=trueList active profiles. Pass full=true to include system_prompt, KB and tool bindings.
/v1/profiles/{profile_id}Always returns the full payload.
/v1/profilescurl -X POST https://omra.pro/v1/profiles \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Support v2",
"system_prompt": "You are a polite support agent.",
"model_slug": "gpt-4o",
"knowledge_base_ids": ["d4e5f6..."],
"allowed_tool_names": ["save_contact"],
"use_kb": true,
"use_tools": true,
"is_default": false
}'
/v1/profiles/{profile_id}Send only the fields you want to change. Setting is_default: true demotes the previous default.
/v1/profiles/{profile_id}Soft delete — references from agents (conductor_profile_id) keep resolving for audit.
Identity & Usage scope: chat
Resolve the company behind an SDK key, and log non-AI usage (voice minutes, Whisper transcription) into the same O₮ billing ledger as model calls.
/v1/meReturns {"company_id": "…", "company_name": "…"}. Lets a Messenger / CRM auto-link to the conductor company without copy-pasting UUIDs.
/v1/usageRecord a non-AI usage event. Rates: voice_call 1.0 O₮/sec (~$0.06/min), whisper 0.1 O₮/sec (~$0.006/min). 1 O₮ = $0.001.
curl -X POST https://omra.pro/v1/usage \
-H "Authorization: Bearer $OAG_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": "voice_call",
"duration_s": 73.4,
"direction": "inbound",
"metadata": {"call_id": "CA-42"}
}'
SDUI SDK
Server-driven UI widgets: embed CRM deal lists, dashboards, forms into any site.
/v1/sdk/tokenExchange long-lived SDK key for a short-lived JWT (5 min TTL).
/v1/sdk/view/{service}/{view_name}scope: viewFetch SDUI view definition + data for the SDK renderer.
/v1/sdk/actionscope: actionExecute a service action from view (e.g. update deal stage, create invoice).
/v1/sdk/keysscope: adminCreate a new SDK API key with scopes and rate limits.
<script type="module" src="https://omra.pro/v1/sdk/sdui-embed.js"></script>
<cockpit-widget
gateway="https://omra.pro"
service="bitrix24"
view="deals_list"
auth-token="oag_xxxxxxxxxxxxx">
</cockpit-widget>
Inbound Webhooks public
Wake up agents from external systems (CRM, Shopify, payment processors). No SDK key required — authenticated by URL secret.
/v1/public/triggers/{company_id}/{webhook_secret}Returns 202 Accepted immediately. Payload routed to Event Bus or a specific agent.
curl -X POST https://omra.pro/v1/public/triggers/$CID/$SECRET \
-H "Content-Type: application/json" \
-d '{"event_topic": "order.created", "payload": {"order_id": "ORD-42"}}'
Errors & Rate Limits
- •
401— missing / invalid / expired key - •
402— insufficient O₮ balance - •
403— scope not granted / invalid webhook secret - •
404— resource not in your company - •
429— rate limit exceeded (default 60 rpm) - •
502— upstream LLM provider error