Cookbooks
Integration recipes for common Asteria use cases — drop-in replacement, shared agents, Power Automate, and programmatic project setup.
Drop-in OpenAI replacement
Switch from OpenAI to Asteria by changing two things: the API key and the base URL. The model field now selects the LLM; agent selects the behavior layer.
Python
from openai import OpenAI
client = OpenAI(
api_key="sk-ast-YOUR_KEY",
base_url="https://api.asteria-labs.com/v1",
)
# Orchestrator mode: RAG + tools
response = client.chat.completions.create(
model="claude-opus-4-6",
extra_body={"agent": "asteria"},
messages=[{"role": "user", "content": "Summarize the attached report."}],
stream=True,
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")TypeScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-ast-YOUR_KEY",
baseURL: "https://api.asteria-labs.com/v1",
});
const completion = await client.chat.completions.create({
model: "claude-opus-4-6",
// @ts-ignore — Asteria extension
agent: "asteria",
messages: [{ role: "user", content: "What are our top 5 risks?" }],
});
console.log(completion.choices[0].message.content);Environment variables
export OPENAI_API_KEY="sk-ast-YOUR_KEY"
export OPENAI_BASE_URL="https://api.asteria-labs.com/v1"
# OpenAI SDK picks these up automatically
# You still need to pass agent in the request bodyEmbed a shared agent in a web app
Create a custom agent once in the platform, share it, then call it by slug from any application.
1. Create and share the agent
In the platform, open the Agent Builder:
- Set name, system prompt, tools.
- Set visibility to Shared.
- Save — the slug appears below the agent name (e.g.,
hr-bot-h26dx).
Discover available agents via GET /v1/agents.
2. Backend proxy (Node.js + Express)
Keep the API key server-side:
import express from "express";
import OpenAI from "openai";
const app = express();
app.use(express.json());
const asteria = new OpenAI({
apiKey: process.env.ASTERIA_API_KEY,
baseURL: process.env.ASTERIA_BASE_URL,
});
app.post("/api/chat", async (req, res) => {
res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache");
res.setHeader("Connection", "keep-alive");
const stream = await asteria.chat.completions.create({
model: "gpt-4o",
// @ts-ignore
agent: "hr-bot-h26dx",
messages: [{ role: "user", content: req.body.message }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) res.write(`data: ${JSON.stringify({ content })}\n\n`);
}
res.write("data: [DONE]\n\n");
res.end();
});
app.listen(3000);Call from Power Automate
Use Power Automate's HTTP action. Non-streaming only — set stream: false.
HTTP action:
| Field | Value |
|---|---|
| Method | POST |
| URI | https://api.asteria-labs.com/v1/chat/completions |
| Headers | Authorization: Bearer sk-ast-YOUR_KEY, Content-Type: application/json |
Body (custom agent):
{
"model": "claude-opus-4-6",
"agent": "hr-bot-h26dx",
"messages": [{"role": "user", "content": "@{triggerBody()?['message']}"}]
}Parse JSON the response — the reply is at choices[0].message.content.
Tips: Set timeout ≥ 120 s. Wrap in a Scope with "Configure run after" to handle 429 errors.
Programmatic project setup
Use the Admin API to provision projects, keys, and members from CI or automation scripts.
Requires an admin key (sk-ast-adm-...) — create one under Settings → Admin API Keys.
import httpx
BASE = "https://api.asteria-labs.com/v1/organization"
HEADERS = {"Authorization": "Bearer sk-ast-adm-YOUR_KEY"}
# Create a project
project = httpx.post(
f"{BASE}/projects",
headers=HEADERS,
json={"name": "New Team Project"},
).raise_for_status().json()
project_id = project["id"]
# Create an API key for it
key = httpx.post(
f"{BASE}/projects/{project_id}/api-keys",
headers=HEADERS,
json={"name": "ci-pipeline", "rate_limit_rpm": 30},
).raise_for_status().json()
print("API key (save this!):", key["key"]) # shown only once
# Add a team member
httpx.post(
f"{BASE}/projects/{project_id}/users",
headers=HEADERS,
json={"user_id": 42, "role": "editor"},
).raise_for_status()
# Query org usage for the current month
from datetime import date
today = date.today()
usage = httpx.get(
f"{BASE}/usage",
headers=HEADERS,
params={"start_date": date(today.year, today.month, 1).isoformat(), "end_date": today.isoformat()},
).raise_for_status().json()
print(f"Requests: {usage['total_requests']}, Cost: ${usage['estimated_cost_usd']:.2f}")Developer Guide
Authentication, routing modes, SDK setup, and error reference for the Asteria API.
Chat Completions
OpenAI-compatible chat completions endpoint. Supports both streaming (SSE) and non-streaming responses. **Routing modes** — controlled by the `model` + `agent` fields: - **Gateway mode** (`agent` omitted): pure LLM proxy, no system prompt, no tools. Rate limiting and budget enforcement still apply. - **Orchestrator mode** (`agent: "asteria"`): full Asteria agent with RAG, web search, code execution, and sub-agents. - **Custom agent mode** (`agent: "<slug>"`): invoke a shared custom agent by slug. The agent's system prompt and tools are applied.