Available
Models
Call GET /v1/models to retrieve a live list with metadata.
Loading…
Reference
API Documentation
All endpoints speak JSON. The /v1/ routes are OpenAI-compatible — drop in any client library without changes.
POST
/v1/chat/completions
Send a list of messages and receive a completion. Supports blocking and streaming modes.
Request body
{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello, can you help me?" }
],
"max_tokens": 1024
}
Response
{
"id": "chatcmpl-1718000000000",
"object": "chat.completion",
"created": 1718000000,
"model": "gpt-4o",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Of course! What do you need?" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 20, "completion_tokens": 9, "total_tokens": 29 }
}
POST
/v1/chat/completions · stream: true
Add "stream": true to receive a server-sent events stream. Each event carries a delta.content fragment. Ends with data: [DONE].
SSE stream
data: {"choices":[{"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"choices":[{"delta":{"content":"Hey! "},"finish_reason":null}]}
data: {"choices":[{"delta":{"content":"How can I help?"},"finish_reason":null}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}]}
data: [DONE]
Reading the stream (JS)
const res = await fetch('https://grey-api.vercel.app/v1/chat/completions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello!' }], stream: true })
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
let buf = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buf += decoder.decode(value, { stream: true });
const lines = buf.split('\n');
buf = lines.pop();
for (const line of lines) {
if (!line.startsWith('data:')) continue;
const payload = line.slice(5).trim();
if (!payload || payload === '[DONE]') continue;
const chunk = JSON.parse(payload);
const text = chunk.choices?.[0]?.delta?.content;
if (text) process.stdout.write(text);
}
}
GET
/v1/models
Returns all enabled models and their metadata in the OpenAI models list format.
Legacy
POST
/api/chat
Original endpoint — fully supported alongside the v1 routes.
Request body
{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello, can you help me?" }
],
"options": { "max_tokens": 2000 }
}
Response
{
"model": "gpt-4o",
"response": "Of course! What do you need?",
"response_type": "text",
"usage": { "prompt_tokens": 20, "completion_tokens": 9, "total_tokens": 29 }
}
Interactive
Playground
Requests go directly to the live API.
Simple
Advanced
JSON Editor
Stream response
Integration
Code Examples
Swap in your deployment URL where needed.
JavaScript
OpenAI SDK
Python
cURL
Java
const res = await fetch('https://grey-api.vercel.app/v1/chat/completions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello, how are you?' }
]
})
});
const data = await res.json();
console.log(data.choices[0].message.content);