OpenAI compatibility
Mindforge implements the OpenAI chat completions API, so you can use any OpenAI-compatible SDK or tool to interact with your characters.
How it works
- Create a character with a personality, capabilities, and knowledge
- Point any OpenAI SDK at
https://api.mindforge.ai/v1and use your Mindforge API key - Pass the character ID as the
modelfield
Behind the scenes, when a request hits /v1/chat/completions, Mindforge resolves the model field to your character and generates a response using the character's full configuration — system prompt, RAG context, and tools.
Setup
python
from openai import OpenAI
client = OpenAI(
base_url="https://api.mindforge.ai/v1",
api_key="sk-mf-YOUR_KEY",
)
# Non-streaming
response = client.chat.completions.create(
model="character_PuTlWmWuynYZu8sP", # your character ID
messages=[
{"role": "user", "content": "Tell me about the castle."}
],
)
print(response.choices[0].message.content)
# Streaming
stream = client.chat.completions.create(
model="character_PuTlWmWuynYZu8sP",
messages=[
{"role": "user", "content": "Tell me about the castle."}
],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")typescript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.mindforge.ai/v1",
apiKey: "sk-mf-YOUR_KEY",
});
// Non-streaming
const response = await client.chat.completions.create({
model: "character_PuTlWmWuynYZu8sP", // your character ID
messages: [
{ role: "user", content: "Tell me about the castle." },
],
});
console.log(response.choices[0].message.content);
// Streaming
const stream = await client.chat.completions.create({
model: "character_PuTlWmWuynYZu8sP",
messages: [
{ role: "user", content: "Tell me about the castle." },
],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}Supported features
| Feature | Supported |
|---|---|
POST /v1/chat/completions | Yes |
GET /v1/models | Yes |
| Streaming (SSE) | Yes |
| Non-streaming | Yes |
| Tool calls | Yes |
| Multi-turn conversations | Yes |
temperature, max_tokens, top_p, stop | Accepted (passed through) |
What's different from OpenAI
modelis a character ID, not a language model name. Pass your character's ID (e.g.character_PuTlWmWuynYZu8sP) as the model.- System messages are ignored. Mindforge builds its own system prompt from the character's configuration and RAG context. You don't need to (and can't) set a system message.
- Tool definitions come from capabilities. The character's attached capabilities are automatically available as tools. You don't need to pass
toolsin the request. character_idis also accepted. For backwards compatibility, you can passcharacter_idin the request body instead ofmodel.
Listing available models
sh
curl https://api.mindforge.ai/v1/models \
-H "Authorization: Bearer $MINDFORGE_API_KEY"Returns your characters in the standard OpenAI model list format:
json
{
"object": "list",
"data": [
{
"id": "character_PuTlWmWuynYZu8sP",
"object": "model",
"created": 1714000000,
"owned_by": "mindforge"
}
]
}