Chat Completions
Сообщения, потоковая передача, инструменты, JSON-ответ, картинки на входе и генерация картинок через чат.
Скачать инструкцию для агента .mdИспользуйте /v1/chat/completions как основной текстовый маршрут. Он же нужен для моделей Gemini, которые возвращают картинки через чат.
Базовый запрос
Запрос
curl https://api.aigate.shop/v1/chat/completions \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-5.5", "messages": [ { "role": "system", "content": "You are concise." }, { "role": "user", "content": "Explain what AIGate does in one sentence." } ], "temperature": 0.4, "max_tokens": 120, "stream": false }'Ответ
{ "id": "gate-1779703910", "object": "chat.completion", "created": 1779703910, "model": "openai/gpt-5.5", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "AIGate lets you call enabled AI models through one OpenAI-compatible API." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 34, "completion_tokens": 19, "total_tokens": 53 }}Потоковая передача
Потоковый запрос
curl https://api.aigate.shop/v1/chat/completions \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-5.5", "messages": [{ "role": "user", "content": "Count to three." }], "stream": true, "stream_options": { "include_usage": true } }'SSE-ответ
data: {"id":"gate-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"One"}}]}data: {"id":"gate-...","object":"chat.completion.chunk","choices":[{"delta":{"content":", two"}}]}data: {"id":"gate-...","object":"chat.completion.chunk","choices":[{"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":4,"total_tokens":16}}data: [DONE]Картинка на входе
json
{ "model": "openai/gpt-5.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What is visible in this image?" }, { "type": "image_url", "image_url": { "url": "https://example.com/image.png" } } ] } ]}Инструменты
json
{ "model": "openai/gpt-5.5", "messages": [{ "role": "user", "content": "What is the weather in Paris?" }], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get weather by city", "parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] } } } ], "tool_choice": "auto"}JSON-ответ
json
{ "model": "openai/gpt-5.5", "messages": [{ "role": "user", "content": "Return {ok: true} as JSON." }], "response_format": { "type": "json_object" }}