cURL
curl -X POST https://api.aiql.io/v1/chat/completions \
-H "Authorization: Bearer $AIQL_API_KEY" \
-H "AiQL-Workspace: $AIQL_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{"model": "ask", "messages": [{"role": "user", "content": "list every invoice over $1,000 from last quarter"}]}'import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.aiql.io/v1",
api_key=os.environ["AIQL_API_KEY"],
default_headers={"AiQL-Workspace": "ws_3a1b"},
)
completion = client.chat.completions.create(
model="ask",
messages=[
{
"role": "user",
"content": "list every invoice over $1,000 from last quarter",
}
],
)
print(completion.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.aiql.io/v1",
apiKey: process.env.AIQL_API_KEY,
defaultHeaders: { "AiQL-Workspace": "ws_3a1b" },
});
const completion = await client.chat.completions.create({
model: "ask",
messages: [
{
role: "user",
content: "list every invoice over $1,000 from last quarter",
},
],
});
console.log(completion.choices[0].message.content);
{
"id": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"annotations": [
{
"file_citation": {
"filename": "<string>"
},
"type": "file_citation",
"start_index": 123,
"end_index": 123
}
],
"sources": [
{
"filename": "<string>",
"title": "<string>",
"page": 123,
"snippet": "<string>",
"cited": false
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
},
"object": "chat.completion"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Chat Completions
Create Chat Completion
POST
/
v1
/
chat
/
completions
cURL
curl -X POST https://api.aiql.io/v1/chat/completions \
-H "Authorization: Bearer $AIQL_API_KEY" \
-H "AiQL-Workspace: $AIQL_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{"model": "ask", "messages": [{"role": "user", "content": "list every invoice over $1,000 from last quarter"}]}'import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.aiql.io/v1",
api_key=os.environ["AIQL_API_KEY"],
default_headers={"AiQL-Workspace": "ws_3a1b"},
)
completion = client.chat.completions.create(
model="ask",
messages=[
{
"role": "user",
"content": "list every invoice over $1,000 from last quarter",
}
],
)
print(completion.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.aiql.io/v1",
apiKey: process.env.AIQL_API_KEY,
defaultHeaders: { "AiQL-Workspace": "ws_3a1b" },
});
const completion = await client.chat.completions.create({
model: "ask",
messages: [
{
role: "user",
content: "list every invoice over $1,000 from last quarter",
},
],
});
console.log(completion.choices[0].message.content);
{
"id": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"annotations": [
{
"file_citation": {
"filename": "<string>"
},
"type": "file_citation",
"start_index": 123,
"end_index": 123
}
],
"sources": [
{
"filename": "<string>",
"title": "<string>",
"page": 123,
"snippet": "<string>",
"cited": false
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
},
"object": "chat.completion"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
API key or UI session JWT passed as a Bearer token.
Headers
ID of the workspace the request operates on.
Body
application/json