Loading...
Loading...
Invoke orq.ai deployments, agents, and models via the Python SDK or HTTP API. Use when a user wants to call a deployment with prompt variables, invoke an agent in a conversation, or call a model directly through the AI Router. Do NOT use for creating or editing deployments/agents (use optimize-prompt or build-agent). Do NOT use for running evaluations (use run-experiment).
npx skill4agent add orq-ai/assistant-plugins invoke-deploymentORQ_API_KEY{{variable}}identity.idstream=Truesearch_entitiesoptimize-promptbuild-agentrun-experimentanalyze-trace-failuressetup-observabilityoptimize-promptbuild-agentrun-experimentsetup-observabilityInvoke Progress:
- [ ] Phase 1: Discover — identify the target resource (deployment / agent / model)
- [ ] Phase 2: Configure — determine inputs/variables, identity, and options
- [ ] Phase 3: Invoke — call the resource and verify the response
- [ ] Phase 4: Integrate — deliver production-ready codeinputsinputs{{variables}}inputs{{variable}}{{variable_name}}messagesmessages{{variable}}variablesidentityiddisplay_nameemailmetadatalogo_urltagsstream=Truedocumentstask_idThis phase is a one-time setup step — its purpose is to identify the key and prompt variables needed to write the integration code. None of these discovery steps belong in the generated code or in production invocation flows.
inputsresponses.createsearch_entitiestype: "deployment"type: "agent"{{variable}}curl -s -H "Authorization: Bearer $ORQ_API_KEY" \
"https://api.orq.ai/v2/deployments/<key>/config"{{variable_name}}inputs{{variable}}{{variable}}inputsmessages: [{role: "user", content: "..."}]inputsmessagesmessagesinputsinputs{{variable_name}}inputs| Pattern | When | What to pass |
|---|---|---|
| Variable substitution | Prompt has | |
| Message appending | Prompt has no variables | |
| Mixed | Prompt has variables AND needs user input | Both |
{{variable}}| Prompt variable | | Example |
|---|---|---|
| | |
| | |
identityid{ "id": "user_<unique_id>", "display_name": "Jane Doe", "email": "jane@example.com" }| Use case | Mode |
|---|---|
| User-facing UI, chatbot | |
| Background job, batch, eval | |
| Option | Resource | Purpose |
|---|---|---|
| Deployments | Inject ad-hoc text chunks (no KB needed) |
| Both | Attach custom tags to the trace |
| Deployments | Pass routing data for conditional model routing |
| Deployments | Return KB chunk sources in the response |
| Deployments | Return token usage in the response |
| Deployments | Return mock content without calling LLM (for testing) |
| Both | Group related invocations by thread ID |
| Agents | Associate memory stores with a specific user/session |
| Agents | Return immediately with task ID (async execution) |
| Agents | Replace template variables in system prompt/instructions |
| Deployments | Filter KB chunks by metadata (eq, ne, gt, in, etc.) |
choices[0].message.contentresponse.output[0].parts[0].textresponse.task_idresponse.telemetry.trace_idimport os
from orq_ai_sdk import Orq
client = Orq(api_key=os.environ["ORQ_API_KEY"])
# Pattern 1: variable substitution
# Use when the prompt template contains {{variable}} placeholders.
# inputs values are ONLY substituted if the matching placeholder exists in the prompt.
response = client.deployments.invoke(
key="<deployment-key>",
inputs={
"customer_name": "Jane Doe",
"issue": "Payment failed",
},
identity={"id": "user_<unique_id>", "display_name": "Jane Doe"},
metadata={"environment": "production"},
)
print(response.choices[0].message.content)
# Pattern 2: message appending
# Use when the prompt has no {{variable}} placeholders — pass the user's question via messages.
response = client.deployments.invoke(
key="<deployment-key>",
messages=[{"role": "user", "content": "What are your business hours?"}],
identity={"id": "user_<unique_id>"},
)
print(response.choices[0].message.content)
# Pattern 3: mixed — variables + user message
response = client.deployments.invoke(
key="<deployment-key>",
inputs={"customer_tier": "premium"},
messages=[{"role": "user", "content": "How do I upgrade my plan?"}],
identity={"id": "user_<unique_id>"},
)
print(response.choices[0].message.content)
# Streaming (works with any pattern above)
response = client.deployments.invoke(
key="<deployment-key>",
inputs={"variable_name": "value"},
identity={"id": "user_<unique_id>"},
stream=True,
)
for chunk in response:
print(chunk, end="", flush=True)# Pattern 1: variable substitution (prompt has {{variable}} placeholders)
curl -s -X POST https://api.orq.ai/v2/deployments/invoke \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "<deployment-key>",
"inputs": {"customer_name": "Jane Doe", "issue": "Payment failed"},
"identity": {"id": "user_<unique_id>", "display_name": "Jane Doe"},
"metadata": {"environment": "production"}
}' | jq
# Pattern 2: message appending (prompt has no {{variable}} placeholders)
curl -s -X POST https://api.orq.ai/v2/deployments/invoke \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "<deployment-key>",
"messages": [{"role": "user", "content": "What are your business hours?"}],
"identity": {"id": "user_<unique_id>"}
}' | jq
# Pattern 3: mixed — variables + user message
curl -s -X POST https://api.orq.ai/v2/deployments/invoke \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "<deployment-key>",
"inputs": {"customer_tier": "premium"},
"messages": [{"role": "user", "content": "How do I upgrade my plan?"}],
"identity": {"id": "user_<unique_id>"}
}' | jqimport os
from orq_ai_sdk import Orq
client = Orq(api_key=os.environ["ORQ_API_KEY"])
# Single turn — note: agents use parts format, NOT OpenAI-style content
response = client.agents.responses.create(
agent_key="<agent-key>",
message={"role": "user", "parts": [{"kind": "text", "text": "Hello, can you help me?"}]},
identity={"id": "user_<unique_id>", "display_name": "Jane Doe"},
)
print(response.output[0].parts[0].text)
# Multi-turn: save task_id and pass it in follow-ups
task_id = response.task_id
follow_up = client.agents.responses.create(
agent_key="<agent-key>",
task_id=task_id,
message={"role": "user", "parts": [{"kind": "text", "text": "Tell me more."}]},
)
print(follow_up.output[0].parts[0].text)curl -s -X POST https://api.orq.ai/v2/agents/<agent-key>/responses \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": {
"role": "user",
"parts": [{"kind": "text", "text": "Hello, can you help me?"}]
},
"identity": {"id": "user_<unique_id>", "display_name": "Jane Doe"}
}' | jqimport { Orq } from "@orq-ai/node";
const client = new Orq({ apiKey: process.env.ORQ_API_KEY });
const response = await client.agents.responses.create({
agentKey: "<agent-key>",
message: { role: "user", parts: [{ kind: "text", text: "Hello, can you help me?" }] },
identity: { id: "user_<unique_id>", displayName: "Jane Doe" },
});
console.log(response.output[0].parts[0].text);
// Multi-turn
const followUp = await client.agents.responses.create({
agentKey: "<agent-key>",
taskId: response.taskId,
message: { role: "user", parts: [{ kind: "text", text: "Tell me more." }] },
});
console.log(followUp.output[0].parts[0].text);openaiimport os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ORQ_API_KEY"],
base_url="https://api.orq.ai/v2/router",
)
response = client.chat.completions.create(
model="openai/gpt-4.1", # always use provider/model format
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"},
],
)
print(response.choices[0].message.content)curl -s -X POST https://api.orq.ai/v2/router/chat/completions \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4.1",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}' | jq| Anti-Pattern | What to Do Instead |
|---|---|
Invoking a deployment without | Always find and pass every |
Passing | |
Hardcoding | Use |
Using OpenAI message format for agents ( | Use A2A parts format: |
Skipping | Always pass identity — enables per-user analytics and cost attribution |
Using | Use |
Not saving | Store |
| Using model name without provider prefix | Use |
| Not checking the trace after first invocation | Use |
Using | Use |