Server-Sent Events (SSE)
Enable streaming by settingstream: true in your request. The response will be delivered as Server-Sent Events.
curl --request POST \
--url https://geoff.ai/api/v1/text/chat \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "magma",
"messages": [{"role": "user", "content": "Write a short story."}],
"stream": true
}'
import requests
response = requests.post(
"https://geoff.ai/api/v1/text/chat",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "magma",
"messages": [{"role": "user", "content": "Write a short story."}],
"stream": True,
},
stream=True,
)
for line in response.iter_lines():
if line:
print(line.decode("utf-8"))
const response = await fetch("https://geoff.ai/api/v1/text/chat", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "magma",
messages: [{ role: "user", content: "Write a short story." }],
stream: true,
}),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value));
}