Chat completions
POST /v1/chat/completions takes the same request as the OpenAI Chat Completions API, so existing client libraries work by changing the base URL and key.
Supported fields: model, messages, max_tokens, temperature, top_p and stop. max_tokens sets the most a reply can cost, so it is held before the request runs; it defaults to 1024. Streaming isn’t supported yet.
curl https://nexus.promptscenes.in/api/v1/chat/completions \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llm-slug",
"messages": [
{
"role": "user",
"content": "Write a haiku about APIs."
}
],
"max_tokens": 256
}'
import os, requests
resp = requests.post(
"https://nexus.promptscenes.in/api/v1/chat/completions",
headers={"Authorization": f"Bearer {os.environ['NEXUS_API_KEY']}"},
json={
"model": "llm-slug",
"messages": [{
"role": "user",
"content": "Write a haiku about APIs.",
}],
"max_tokens": 256,
},
timeout=120,
)
resp.raise_for_status()
print(resp.json()["choices"][0]["message"]["content"])
const resp = await fetch("https://nexus.promptscenes.in/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.NEXUS_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "llm-slug",
"messages": [
{
"role": "user",
"content": "Write a haiku about APIs."
}
],
"max_tokens": 256
}),
});
const data = await resp.json();
console.log(data.choices[0].message.content);
The response
You get the OpenAI response shape, plus a nexus object with what the request charged in credits and its request_id.
Using an OpenAI SDK
Point the client at https://nexus.promptscenes.in/api/v1 and pass your Nexus key as the API key. Use model IDs from the chat models list.