Text & Code Requests
These examples use the Flex247 OpenAI Compatible endpoint.
Basic chat
bash
curl https://api.noflex.work/v1/chat/completions \
-H "Authorization: Bearer sk-your-flex247-key" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-id",
"messages": [{"role":"user","content":"Write one product tagline."}]
}'System instructions
json
{
"model": "your-model-id",
"messages": [
{"role": "system", "content": "Act as a senior code reviewer. State risks first, then propose the smallest safe change."},
{"role": "user", "content": "Review the following function."}
]
}Multi-turn chat
Include the history you want the model to retain:
js
const messages = [
{ role: 'user', content: 'Suggest three project names.' },
{ role: 'assistant', content: 'Nova, Orbit, Canvas' },
{ role: 'user', content: 'Choose the second and write a tagline.' }
]
const result = await client.chat.completions.create({
model: 'your-model-id',
messages
})JSON output
For models supporting structured output, request JSON and still validate the schema in production:
json
{
"model": "your-model-id",
"messages": [
{"role":"user","content":"Return JSON with title, summary and tags."}
],
"response_format": {"type":"json_object"}
}Timeouts and retries
- Retry timeouts, interrupted connections and selected
5xxerrors only a limited number of times. - Do not repeatedly retry
401; verify the key first. - Use exponential backoff for
429and reduce concurrency. - Stream long tasks when supported.