Documentación API

Threads de chat compatibles con OpenAI + SDK SDUI. Autentica con una clave SDK del cockpit.

Autenticación

Todos los endpoints públicos usan autenticación Bearer. Genera una clave en /sdk-keys del cockpit. Las claves tienen scopes:

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.

POST/v1/chat/completions

Each 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.

GET/v1/models

List 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.

OpenAI — 38 models
gpt-4-turbo · gpt-4-turbo-2024-04-09
gpt-4o · gpt-4o-2024-05-13 · gpt-4o-2024-08-06 · gpt-4o-2024-11-20
gpt-4o-mini · gpt-4o-mini-2024-07-18
gpt-5 · gpt-5-2025-08-07 · gpt-5-chat-latest
gpt-5-mini · gpt-5-mini-2025-08-07 · gpt-5-nano · gpt-5-nano-2025-08-07
gpt-5.1 · gpt-5.1-2025-11-13 · gpt-5.1-chat-latest
gpt-5.2 · gpt-5.2-2025-12-11 · gpt-5.2-chat-latest
gpt-5.3-chat-latest
gpt-5.4 · gpt-5.4-2026-03-05 · gpt-5.4-mini · gpt-5.4-mini-2026-03-17 · gpt-5.4-nano · gpt-5.4-nano-2026-03-17
gpt-5.5 · gpt-5.5-2026-04-23
o1 · o1-2024-12-17 · o3 · o3-2025-04-16 · o3-mini · o3-mini-2025-01-31 · o4-mini · o4-mini-2025-04-16
OpenRouter — 16 models

Cross-provider fallback (Claude, Llama, Qwen, DeepSeek, Mistral via OpenRouter).

or-claude-opus-4 · or-claude-sonnet-4 · or-claude-3-5-haiku
or-gpt-4o · or-gpt-4o-mini · or-gpt-4-turbo · or-o3-mini · or-o4-mini
or-deepseek-chat-v3 · or-deepseek-r1 · or-deepseek-v4-flash · or-deepseek-v4-pro
or-llama-3-3-70b · or-llama-4-scout · or-qwen3-235b · or-mistral-large
Z.AI (GLM) — 8 models
glm-4.5 · glm-4.5-air · glm-4.6 · glm-4.6v · glm-4.7
glm-5 · glm-5.1 · glm-5-turbo
DeepSeek — 4 models
deepseek-chat · deepseek-reasoner · deepseek-v4-flash · deepseek-v4-pro
Copilot — 4 models

GitHub Copilot upstream — Claude and GPT routed through Copilot's API.

copilot-gpt-4o · copilot-gpt-4o-mini · copilot-gpt-5.4 · copilot-claude-sonnet-4.6
Gemini — 2 models
gemini-2.5-flash · gemini-2.5-pro

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

Threads, mensajes, runs compatibles con OpenAI Assistants. — stateful alternative to Chat Completions when you want messages and runs to persist across calls.

POST/v1/threads
curl -X POST https://omra.pro/v1/threads \
  -H "Authorization: Bearer $OAG_KEY" \
  -H "Content-Type: application/json" \
  -d '{"metadata": {"user": "alice"}}'
GET/v1/threads/{thread_id}
POST/v1/threads/{thread_id}/messages
curl -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"}'
POST/v1/threads/{thread_id}/messages/bulk

Batch-add multiple messages in one request.

GET/v1/threads/{thread_id}/messages?limit=20&after=…
POST/v1/threads/{thread_id}/runs

Execute a model run on the thread. Non-streaming returns a single RunResponse; stream: true opens an SSE channel.

Request body
  • model — required. Any slug from GET /v1/models.
  • instructions — extra system-prompt layer for this run.
  • stream — boolean (default false). When true, response is SSE.
  • enable_multimodal — boolean (default true). Routes image_url parts 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 (true to force RAG on, false to 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"
  }'
Response (non-streaming)
  • 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.

GET/v1/knowledge

List active collections.

POST/v1/knowledge
curl -X POST https://omra.pro/v1/knowledge \
  -H "Authorization: Bearer $OAG_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Sales playbook", "description": "Internal scripts"}'
DELETE/v1/knowledge/{collection_id}

Soft delete (deactivates the collection; documents preserved for audit).

GET/v1/knowledge/{collection_id}/documents

List up to 500 most recent documents with status (pending / ready / failed).

POST/v1/knowledge/{collection_id}/documentsmultipart/form-data

Returns 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"
DELETE/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.

GET/v1/tools
GET/v1/tools/{tool_id}
POST/v1/tools

Idempotent 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()"
  }'
PATCH/v1/tools/{tool_id}

Partial update of name / description / schema / code / is_active.

DELETE/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.

GET/v1/profiles?full=true

List active profiles. Pass full=true to include system_prompt, KB and tool bindings.

GET/v1/profiles/{profile_id}

Always returns the full payload.

POST/v1/profiles
curl -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
  }'
PATCH/v1/profiles/{profile_id}

Send only the fields you want to change. Setting is_default: true demotes the previous default.

DELETE/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.

GET/v1/me

Returns {"company_id": "…", "company_name": "…"}. Lets a Messenger / CRM auto-link to the conductor company without copy-pasting UUIDs.

POST/v1/usage

Record 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

Widgets server-driven UI: incrusta listados CRM, dashboards, formularios en cualquier sitio.

POST/v1/sdk/token

Exchange long-lived SDK key for a short-lived JWT (5 min TTL).

GET/v1/sdk/view/{service}/{view_name}scope: view

Fetch SDUI view definition + data for the SDK renderer.

POST/v1/sdk/actionscope: action

Execute a service action from view (e.g. update deal stage, create invoice).

POST/v1/sdk/keysscope: admin

Create a new SDK API key with scopes and rate limits.

Web Component
<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.

POST/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"}}'

Errores y rate limits