POST https://api.onlysq.ru/ai/v2
Generates a text response to a user message(s).
Request
This endpoint expects an object.
model
string Required
The name of a OnlySq AI model which will process the request
request
dict Required
Query data dictionary.
Contains:
messages
list RequiredA list of chat messages in chronological order, representing a conversation between the user and the model. Messages can be from
User
,Assistant
andSystem
roles.meta
dict OptionalAn optional dictionary previously used by ImaGen models.
Contains:
image_count
int OptionalOptional parameter, previously used when generating with ImaGen
Response
id
string
Unique identifier for the generated reply. Useful for submitting feedback.
object
string
Object initialization for OpenAI SDK.
created
int
Timestamp in UNIX format.
model
string
The model that processed the request.
answer
string Disabled
The old version of receiving a response. Will be completely removed on 05/01/2025
choices
list
The list of completion choices the model generated for the input prompt.
Contains:
index
integerIndex of generated response
message
dictAn object containing the response of the model that processed the request
Contains:
role
stringA role of message, can be one of:
User
,Assistant
,System
.content
stringA response text.
finish_reason
stringThe reason a chat request has finished.
stop
: The model finished sending a complete message.error
: The generation failed due to an internal error.
usage
dict
Contains:
prompt_tokens
intThe number of billed input tokens.
completion_tokens
intThe number of billed output tokens.
total_tokens
intTotal number of billed tokens.
user
int
Unique of user by API key. Useful for submitting feedback.
Examples
Request example
import requests
send = {
"model": "gpt-4o-mini",
"request": {
"messages": [
{
"role": "user",
"content": "Hi! Write a short one-line story"
}
]
}
}
request = requests.post('http://api.onlysq.ru/ai/v2', json=send)
print(response["choices"][0]["message"]["content"])
This returns the following response to the console:
Under the streetlight, she found the courage to let go of the letter—and the past.
Response example
{
"id": "chat_XBt6z670WKm7L9BVoCcLZLzTNZ03UJhD6sWqAEUyTgaJvhJA",
"object": "chat.completion",
"created": 1745146202,
"model": "gpt-4o-mini",
"answer": "[OnlySq API] Warning: \"answer\" was disabled in the responses; we recommend rewriting your projects to ensure accessibility to OnlySq API2.0 AI models",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\"Under the full moon, the werewolf realized he'd forgotten his keys—again.\"",
"refusal": null,
"annotations": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 11,
"completion_tokens": 19,
"total_tokens": 30
},
"user": 0
}