Skip to content

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

  1. Create a character with a personality, capabilities, and knowledge
  2. Point any OpenAI SDK at https://api.mindforge.ai/v1 and use your Mindforge API key
  3. Pass the character ID as the model field

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

FeatureSupported
POST /v1/chat/completionsYes
GET /v1/modelsYes
Streaming (SSE)Yes
Non-streamingYes
Tool callsYes
Multi-turn conversationsYes
temperature, max_tokens, top_p, stopAccepted (passed through)

What's different from OpenAI

  • model is 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 tools in the request.
  • character_id is also accepted. For backwards compatibility, you can pass character_id in the request body instead of model.

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"
    }
  ]
}