curl -X POST "$ATAI_API_ENDPOINT/inference/sessions/ses_01jcx4m8t2vq6xn3r7k5hbzw9e/query" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "omega-embedding",
"query": "",
"events": [
{"type": "data.numeric_array", "event_data": {"contents": [[0.12, 0.08, -0.03, 0.15]]}}
]
}'
import os
from openai import OpenAI
session_id = "ses_01jcx5a2k9wq3pn8d6r4tmyv7c" # a session opened on newton-c-2.6
client = OpenAI(
base_url=f"{os.environ['ATAI_API_ENDPOINT']}/inference/sessions/{session_id}",
api_key=os.environ["ATAI_API_KEY"],
)
completion = client.chat.completions.create(
model="newton-c-2.6",
messages=[{"role": "user", "content": "List three checks to run before starting a conveyor belt."}],
)
print(completion.choices[0].message.content)
import OpenAI from 'openai';
const sessionId = 'ses_01jcx5f7h3nb2wq9k4s6xdzr8m'; // a session opened on newton-fusion-1.0
const client = new OpenAI({
baseURL: `${process.env.ATAI_API_ENDPOINT}/inference/sessions/${sessionId}`,
apiKey: process.env.ATAI_API_KEY
});
const response = await client.responses.create({
model: 'newton-fusion-1.0',
input: 'List three checks to run before starting a conveyor belt.'
});
console.log(response.output_text);
{
"errors": [
{
"code": "session_not_running",
"message": "<message>",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
Sessions
Query a Model Session
Send a Direct Query, Chat Completions, or Responses request to one of your sessions on a platform-hosted model
POST
/
api
/
inference
/
sessions
/
{session_id}
/
query
curl -X POST "$ATAI_API_ENDPOINT/inference/sessions/ses_01jcx4m8t2vq6xn3r7k5hbzw9e/query" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "omega-embedding",
"query": "",
"events": [
{"type": "data.numeric_array", "event_data": {"contents": [[0.12, 0.08, -0.03, 0.15]]}}
]
}'
import os
from openai import OpenAI
session_id = "ses_01jcx5a2k9wq3pn8d6r4tmyv7c" # a session opened on newton-c-2.6
client = OpenAI(
base_url=f"{os.environ['ATAI_API_ENDPOINT']}/inference/sessions/{session_id}",
api_key=os.environ["ATAI_API_KEY"],
)
completion = client.chat.completions.create(
model="newton-c-2.6",
messages=[{"role": "user", "content": "List three checks to run before starting a conveyor belt."}],
)
print(completion.choices[0].message.content)
import OpenAI from 'openai';
const sessionId = 'ses_01jcx5f7h3nb2wq9k4s6xdzr8m'; // a session opened on newton-fusion-1.0
const client = new OpenAI({
baseURL: `${process.env.ATAI_API_ENDPOINT}/inference/sessions/${sessionId}`,
apiKey: process.env.ATAI_API_KEY
});
const response = await client.responses.create({
model: 'newton-fusion-1.0',
input: 'List three checks to run before starting a conveyor belt.'
});
console.log(response.output_text);
{
"errors": [
{
"code": "session_not_running",
"message": "<message>",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
Requires version 2.0.1 or later of the Archetype platform.
Overview
A session answers the same three request formats as the Inference API, under the session’s own path. The model uses the session’svalues and state.
| Endpoint | Format |
|---|---|
POST /api/inference/sessions/{session_id}/query | Direct Query |
POST /api/inference/sessions/{session_id}/chat/completions | Chat Completions |
POST /api/inference/sessions/{session_id}/responses | Responses |
https://platform.u1.archetypeai.app/api/inference/sessions/{session_id}.
Request
Session
ses_ ID, from Create Model Session.The session’s model, by any of its names. A body without
model, or one that names a different
model than the session’s, returns 400.curl -X POST "$ATAI_API_ENDPOINT/inference/sessions/ses_01jcx4m8t2vq6xn3r7k5hbzw9e/query" \
-H "Authorization: Bearer $ATAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "omega-embedding",
"query": "",
"events": [
{"type": "data.numeric_array", "event_data": {"contents": [[0.12, 0.08, -0.03, 0.15]]}}
]
}'
import os
from openai import OpenAI
session_id = "ses_01jcx5a2k9wq3pn8d6r4tmyv7c" # a session opened on newton-c-2.6
client = OpenAI(
base_url=f"{os.environ['ATAI_API_ENDPOINT']}/inference/sessions/{session_id}",
api_key=os.environ["ATAI_API_KEY"],
)
completion = client.chat.completions.create(
model="newton-c-2.6",
messages=[{"role": "user", "content": "List three checks to run before starting a conveyor belt."}],
)
print(completion.choices[0].message.content)
import OpenAI from 'openai';
const sessionId = 'ses_01jcx5f7h3nb2wq9k4s6xdzr8m'; // a session opened on newton-fusion-1.0
const client = new OpenAI({
baseURL: `${process.env.ATAI_API_ENDPOINT}/inference/sessions/${sessionId}`,
apiKey: process.env.ATAI_API_KEY
});
const response = await client.responses.create({
model: 'newton-fusion-1.0',
input: 'List three checks to run before starting a conveyor belt.'
});
console.log(response.output_text);
{
"errors": [
{
"code": "session_not_running",
"message": "<message>",
"suggestion": null,
"error_uid": "err-xxxxxxxx"
}
]
}
Important Notes
409withsession_not_runningmeans the session has ended. Open a new session and send the query there. You don’t need to read the session’serrorfirst.404means the session doesn’t exist or isn’t visible to you.400also meansmodelis missing or names a different model than the session’s.- A
503doesn’t mean the session has ended. Retry. - Every other error is the same as on the endpoint without a session. See Errors.
Was this page helpful?