Currently, only character type resources are supported.

Slug Format

m:model>c:character
Where:
  • m: specifies the model (e.g., m:openrouter/auto)
  • c: specifies a character resource by its slug
order does not matter.

How It Works

  1. The API parses your desired model and character from the slug
  2. It fetches the referenced character from the database
  3. It constructs system instructions with character’s details
  4. Your request is forwarded to OpenRouter with this enhanced prompt
All of this happens in the nearest edge location and each process is cached for fastest response times.

Making API Requests

const response = await fetch('https://api.charactergateway.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: 'm:openrouter/auto>c:my-character-slug',
    messages: [
      { role: 'user', content: 'Hello!' }
    ],
    max_tokens: 150
  })
});

Example: Character Conversation

const response = await fetch('https://api.charactergateway.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: 'm:anthropic/claude-3-opus-20240229>c:einstein',
    messages: [
      { role: 'user', content: 'Can you explain relativity in simple terms?' }
    ],
    temperature: 0.7,
    stream: true
  })
});

Notes & Limitations

  1. Only character resources (c: prefix) are currently supported
  2. If no model is specified, the system defaults to openrouter/auto
  3. If a referenced resource cannot be found, the API returns a 404 error