> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alakazam.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a character

> Create a talk-to-able character (a SMWorld subtype: a stance-graph plus a "brain" of persona / lore / voice). Three modes — IMPORT a complete character world ({ world }, e.g. an example file), EXPLICIT ({ name, persona, stances:[{id,label,expression}], subject, style, voiceId }), or AUTHORED ({ authored:true, premise|frame_* } — the platform invents the profile + stances). Reserves one generation against your daily quota.




## OpenAPI

````yaml /alakazam-v1.yaml post /v1/characters
openapi: 3.1.0
info:
  title: Alakazam — Programmable Worlds API
  version: '1.0'
  description: >
    **Alakazam is the programmable worlds API.** Generate playable, AI-rendered
    worlds from a prompt or an image, program their logic, and embed them in
    your own products and games.


    A world is *programmable*: a live graph of states and events you generate,
    then read, edit, fork, drive, and react to through the API. Two surfaces: a
    **Creation API** (generate, read, manage, fork worlds) and a **Runtime/Embed
    API** (mint short-lived session tokens your end-users' browsers use to boot
    an embedded world).


    **Authentication.** Two schemes. Management endpoints (`/v1/apps*`) use your
    Supabase user session. Data endpoints use an **API key** issued per app:
    `pk_…` (publishable, browser-safe, read + embed) and `sk_…` (secret,
    server-only, create worlds + mint sessions). Never ship a secret key to a
    browser.


    **Usage & quota.** Generations and session mints are metered per app and
    reserved before any GPU spend; exceeding the daily quota returns `402`.
servers:
  - url: https://api.alakazam.gg
    description: Production (placeholder — set to your conjure-service host)
security: []
tags:
  - name: Apps & Keys
    description: >-
      Create apps (tenants) and manage API keys. Authenticated with your user
      session.
  - name: Worlds
    description: >-
      Create, read, manage, and fork SMWorld games. Authenticated with an API
      key.
  - name: Graph editing
    description: >
      Read and program a world's graph — states (nodes), events (edges), and the
      entrance — with deterministic CRUD, a batch op vocabulary, a
      natural-language kernel-agent edit, and the kernel validate/lint gate.
      Every write is validated fail-closed before it persists. Authenticated
      with an API key.
  - name: Versions
    description: >
      Snapshot, branch, check out, and diff a world's graph. Versions form a
      branching tree of full snapshots; a HEAD pointer tracks the working graph.
      Authenticated with an API key.
  - name: Characters
    description: >
      Create, manage, and talk to characters — a SMWorld subtype that pairs a
      stance-graph with a "brain" (persona, lore, voice). CRUD is authenticated
      with an API key; the live talk turn (/say) and voice (/tts) are called
      from the browser with a short-lived session token.
  - name: Sessions
    description: Mint short-lived runtime tokens for embedding a world.
  - name: Usage
    description: Per-app usage and quota.
  - name: Webhooks
    description: >-
      Register HTTPS endpoints to receive signed server-side event
      notifications. Managed with your user session.
paths:
  /v1/characters:
    post:
      tags:
        - Characters
      summary: Create a character
      description: >
        Create a talk-to-able character (a SMWorld subtype: a stance-graph plus
        a "brain" of persona / lore / voice). Three modes — IMPORT a complete
        character world ({ world }, e.g. an example file), EXPLICIT ({ name,
        persona, stances:[{id,label,expression}], subject, style, voiceId }), or
        AUTHORED ({ authored:true, premise|frame_* } — the platform invents the
        profile + stances). Reserves one generation against your daily quota.
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            A retried request with the same key returns the original result
            without re-creating.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                world:
                  type: object
                  description: >-
                    IMPORT mode — a complete character world (world.scene +
                    world.character).
                name:
                  type: string
                authored:
                  type: boolean
                  description: >-
                    AUTHORED mode — invent the profile + stances from a
                    frame/premise.
                premise:
                  type: string
                frame_b64:
                  type: string
                frame_url:
                  type: string
                cover:
                  type: string
                  description: An explicit cover/seed-frame URL.
                subject:
                  type: string
                  description: EXPLICIT — the anti-drift visual SUBJECT lock.
                style:
                  type: string
                  description: EXPLICIT — the visual STYLE phrase.
                persona:
                  type: string
                  description: EXPLICIT — who they are (the brain).
                scene:
                  type: string
                greeting:
                  type: string
                lore:
                  type: string
                examples:
                  type: string
                stances:
                  type: array
                  description: >-
                    EXPLICIT — the emotional stance palette; each is one visual
                    state + a brain mood.
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                      label:
                        type: string
                      mood:
                        type: string
                      expression:
                        type: string
                voiceId:
                  type: string
                  description: ElevenLabs voice id.
                modelId:
                  type: string
                free:
                  type: boolean
                intro:
                  type: object
                  properties:
                    kicker:
                      type: string
                    title:
                      type: string
                    hint:
                      type: string
      responses:
        '200':
          description: Character created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCharacterResponse'
        '400':
          description: Missing required fields for the chosen mode
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Daily generation quota exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Character failed schema validation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Quota backend unavailable (fail-closed)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateCharacterResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        slug:
          type: string
          nullable: true
        kind:
          type: string
          example: character
        cover:
          type: string
          nullable: true
        schemaVersion:
          type: string
          example: '1.0'
    Error:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message.
        errors:
          type: array
          items:
            type: string
          description: Field-level validation errors (e.g. on 422 from POST /v1/worlds).
        schemaVersion:
          type: string
      required:
        - detail
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        An app API key, e.g. `Authorization: Bearer sk_live_…`. Secret (`sk_`)
        for writes/sessions; publishable (`pk_`) for read/embed.

````