SDKs and examples
Examples
Working code for the most common Atlas paths. Copy, paste, swap your key.
Hello, Atlas
bash# curl
curl https://api.newmen.ai/v1/chat/completions \
-H "Authorization: Bearer $NEWMEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "atlas-1",
"messages": [{ "role": "user", "content": "What is the capital of Japan?" }]
}'Structured extraction
Atlas honours response_format in the OpenAI shape. Combine with a JSON-schema evaluator on the operation for clean ship-gate enforcement.
pythonfrom newmen import Newmen
client = Newmen(api_key=os.environ["NEWMEN_API_KEY"])
system = "Extract the invoice into strict JSON: { invoice_id, amount, due_date }."
res = client.chat.completions.create(
model="atlas-1",
messages=[
{"role": "system", "content": system},
{"role": "user", "content": invoice_text},
],
response_format={"type": "json_object"},
metadata={"operation_id": "extract_invoice"},
)
data = json.loads(res.choices[0].message.content)Tag-then-promote loop
End-to-end: pull tagged calls, build a dataset, run an evaluation, promote. This is the script most customers eventually run from CI.
typescriptimport Newmen from "@newmen-ai/sdk";
const client = new Newmen({ apiKey: process.env.NEWMEN_API_KEY });
// 1. Pull the recent thumbs-up calls.
const calls = await client.calls.list({
operation_id: "summarize_ticket",
rating: "thumbs_up",
limit: 200,
});
// 2. Build a dataset.
const ds = await client.datasets.create({
operation_id: "summarize_ticket",
name: "Tickets v4",
});
await client.datasets.items.add(
ds.id,
calls.items.map(c => ({
source_call_id: c.id,
input: c.request_payload,
expected_output: c.feedback?.correction ?? c.response_payload.choices[0].message.content,
})),
);
// 3. Evaluate.
await client.evaluations.create({
dataset_id: ds.id,
evaluator_ids: ["ev_pii", "ev_judge_quality"],
});
// 4. Promote (ship-gate enforced).
await client.datasets.promote(ds.id);Drop-in for OpenAI clients
Existing OpenAI clients work against Atlas with only a base URL swap. Useful for a no-risk pilot before adopting the Newmen SDKs.
pythonfrom openai import OpenAI
# Same call, different base URL. The Atlas API speaks OpenAI's
# chat-completions surface, so existing OpenAI SDKs work unchanged.
client = OpenAI(
api_key=os.environ["NEWMEN_API_KEY"],
base_url="https://api.newmen.ai/v1",
)
res = client.chat.completions.create(
model="atlas-1",
messages=[{"role": "user", "content": "hi"}],
)