Claude Code Guide
Set up Flaq AI Claude models and explore Claude Code skills
Free to try Qwen Plus Character API for richer persona-driven text roleplay, profile, memory, and stable Alibaba LLM workflows.
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
Accept: 'text/event-stream',
'Content-Type': 'application/json',
'x-session': 'your-session-id'
},
body: JSON.stringify({
model: 'qwen-plus-character',
messages: [
{
role: 'system',
content: 'You are a witty high-school student who speaks with humor and warmth.'
},
{
role: 'user',
content: 'Remember that I prefer lightly sweet milk tea.'
}
],
stream: true,
max_tokens: 1200,
temperature: 0.8,
seed: 12345,
profile: 'You are a witty high-school student who remembers user preferences and stays in character.',
enable_long_term_memory: true,
memory_entries: 50,
skip_save_types: []
})
});
if (!response.ok) {
const errorBody = await response.json().catch(() => null);
throw new Error(errorBody?.error?.message ?? errorBody?.message ?? `HTTP ${response.status}`);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
let assistantText = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const frames = buffer.split(/\r?\n\r?\n/);
buffer = frames.pop() || '';
for (const frame of frames) {
const lines = frame.split(/\r?\n/).filter(Boolean);
let eventName = 'message';
const dataLines = [];
for (const line of lines) {
if (line.startsWith('event:')) {
eventName = line.slice(6).trim();
} else if (line.startsWith('data:')) {
dataLines.push(line.replace(/^data:\s*/, ''));
}
}
const raw = dataLines.join('\n').trim();
if (raw === '[DONE]') {
console.log('\nFinal text:', assistantText);
continue;
}
let payload;
try {
payload = JSON.parse(raw);
} catch {
continue;
}
if (eventName === 'error' || payload.error) {
const msg = payload.error?.message ?? payload.message ?? 'Chat request failed';
throw new Error(msg);
}
const delta = payload.choices?.[0]?.delta;
if (delta?.content) {
assistantText += delta.content;
console.log(assistantText);
}
}
}
import json
import requests
response = requests.post(
'https://api.flaq.ai/api/v1/chat/completions',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json',
'x-session': 'your-session-id',
},
json={
'model': 'qwen-plus-character',
'messages': [
{
'role': 'system',
'content': 'You are a witty high-school student who speaks with humor and warmth.',
},
{
'role': 'user',
'content': 'Remember that I prefer lightly sweet milk tea.',
},
],
'stream': True,
'max_tokens': 1200,
'temperature': 0.8,
'seed': 12345,
'profile': 'You are a witty high-school student who remembers user preferences and stays in character.',
'enable_long_term_memory': True,
'memory_entries': 50,
'skip_save_types': [],
},
stream=True,
)
response.raise_for_status()
event_name = 'message'
assistant_text = ''
for raw_line in response.iter_lines(decode_unicode=True):
if not raw_line:
event_name = 'message'
continue
if raw_line.startswith('event:'):
event_name = raw_line.replace('event:', '', 1).strip()
continue
if raw_line.startswith('data:'):
raw_data = raw_line.replace('data:', '', 1).strip()
if raw_data == '[DONE]':
print('\nFinal text:', assistant_text)
continue
payload = json.loads(raw_data)
if event_name == 'error' or payload.get('error'):
error = payload.get('error') or payload
raise RuntimeError(error.get('message', 'Chat request failed'))
choices = payload.get('choices') or []
if choices:
delta = choices[0].get('delta') or {}
content = delta.get('content')
if content:
assistant_text += content
print(content, end='', flush=True)
curl -N -X POST "https://api.flaq.ai/api/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: text/event-stream" \
-H "Content-Type: application/json" \
-H "x-session: your-session-id" \
-d '{
"model": "qwen-plus-character",
"messages": [
{
"role": "system",
"content": "You are a witty high-school student who speaks with humor and warmth."
},
{
"role": "user",
"content": "Remember that I prefer lightly sweet milk tea."
}
],
"stream": true,
"max_tokens": 1200,
"temperature": 0.8,
"seed": 12345,
"profile": "You are a witty high-school student who remembers user preferences and stays in character.",
"enable_long_term_memory": true,
"memory_entries": 50,
"skip_save_types": []
}'
| Parameters | Price | Original Price | Discount |
|---|
Qwen Plus Character API on Flaq AI provides Alibaba character roleplay LLM access for developers building persona-driven chat, companion apps, storytelling tools, and memory-aware dialogue workflows. This Qwen API integration helps teams create consistent text conversations with reusable character profiles, multi-turn context, and optional long-term memory through a managed production route. It is designed for products that need richer character dialogue, stable personality behavior, and affordable LLM access at scale.
enable_long_term_memory, profile, and a user-defined x-session value.profile as the reusable character profile when long-term memory is enabled.partial: true.partial continuation messages.For group-chat simulation, speaker names are not inferred from profile. Add names manually at the beginning of each message, then append a final assistant message such as Ling Lu: with partial: true so the model continues as that character.
Note Please ensure prompts, character profiles, memory usage, and generated text comply with Alibaba and Flaq AI safety requirements. If an error occurs, revise the request, profile, or memory settings and try again.
Set up Flaq AI Claude models and explore Claude Code skills

Set up Flaq AI GPT models and explore Codex skills
Use Flaq AI LLM models in Hermes Agent
Use GLM 5.2, Kimi K3, and DeepSeek v4 in ZCode
Run DeepSeek Harness with Flaq AI DeepSeek models
Connect AI agents to Flaq image and video generation tools
Use GPT 6 Astra and Claude Fable 5.1 in WorkBuddy