Synchronous Requests
While the Queue system is the more reliable and recommended way to submit requests, we also support synchronous requests endpoint.
Synchronous Requests API
While our Queue system is the more reliable and recommended way to submit requests, we also support synchronous requests endpoint.
Synchronous endpoints are beneficial if when you know the request is quick and you are looking for minimal latency. The drawbacks are:
You need to keep the connection open until receiving the result
The request cannot be interrupted
If the connection is interrupted there is not way to obtain the result
You will be charged for the full request whether or not you were able to receive the result
The endpoint format and parameters are similar to the Queue ones:
https://llm.onerouter.pro/v1/chat/completionsPOST
LLM Model endpoint
https://image.onerouter.pro/v1/images/generationsPOST
Image Generative Model endpoint
https://video.onerouter.pro/v1/videos/generationsPOST
Video Generative Model endpoint
Submit a request
Here is an example of using the curl command to submit a synchronous request:
curl https://llm.onerouter.pro/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "claude-3-5-sonnet@20240620",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'The response will come directly from the model:
{
"id": "msg_bdrk_012eVNJSL4MNxHhwVJMwM9XF",
"model": "claude-3-5-sonnet-20240620",
"object": "chat.completion",
"created": 1760533671,
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "The meaning of life is a profound philosophical question that has been debated by thinkers, philosophers, and religious leaders throughout history. There is no single, universally agreed-upon answer. Different people and cultures have various perspectives on this question. Some common views include:\n\n1. Personal fulfillment: Finding happiness, purpose, and self-actualization.\n\n2. Relationships: Forming meaningful connections with others and contributing to society.\n\n3. Religious or spiritual purposes: Fulfilling a divine plan or achieving spiritual enlightenment.\n\n4. Biological perspective: Surviving and passing on genes to future generations.\n\n5. Existentialist view: Creating our own meaning in an inherently meaningless universe.\n\n6. Hedonistic approach: Maximizing pleasure and minimizing pain.\n\n7. Legacy: Making a lasting impact on the world or future generations.\n\n8. Growth and learning: Continual self-improvement and acquisition of knowledge.\n\n9. Altruism: Helping others and making the world a better place.\n\n10. Absurdist perspective: Accepting that life has no inherent meaning and finding joy in that freedom.\n\nUltimately, the meaning of life is subjective and can vary greatly from person to person. It's up to individuals to determine what gives their life purpose and significance."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 284,
"total_tokens": 298,
"prompt_tokens_details": {
"cached_tokens": 0,
"cached_creation_tokens": 0,
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null,
"ttft": 0,
"response_json": "",
"request_json": "",
"finish_reason": "",
"original_request_id": "",
"completions": ""
}
} Last updated