Basic Usage
The OpenAI Responses API supports both simple string inputs and structured message arrays for chat-based interactions.
Endpoint
POST https://llm.siraya.pro/v1/chat/completions
Input Formats
1. Simple String Input
For quick queries, you can send a simple text prompt.
2. Structured Message Input
The recommended format for multi-turn conversations and system instructions.
{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful travel assistant."},
{"role": "user", "content": "Suggest a 3-day trip to Tokyo."}
]
}
Features
- Stateless Execution: Each request is self-contained.
- Multimodal Content: Support for images and documents in message content (where supported by the model).
- Streaming: Real-time response generation using Server-Sent Events (SSE).
Example: Streaming Response
from openai import OpenAI
client = OpenAI(
base_url="https://llm.siraya.pro/v1",
api_key="<API_KEY>"
)
stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a poem about the ocean."}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")