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

# Prompt Quickstart

> Sync a code-first prompt and attribute runtime calls

## 1. Initialize Moda

```bash theme={"dark"}
moda init
```

`moda init` authenticates the CLI, writes SDK setup guidance, and creates a prompt manifest:

```yaml .moda/prompts.yml theme={"dark"}
version: 1
prompt_paths:
  - "prompts/**/*.prompt.md"
  - "prompts/**/*.prompt.json"
  - "prompts/**/*.prompt.yaml"
  - "prompts/**/*.prompt.yml"
```

## 2. Add a Prompt File

```md prompts/support/triage.prompt.md theme={"dark"}
---
key: support.triage
name: Support triage
system_prompt: You route support tickets to the right team.
model: gpt-4o
---
Ticket:
{{ticket.text}}
```

## 3. Check Status

```bash theme={"dark"}
moda prompts status
```

The command prints JSON showing new, changed, unchanged, and deleted prompt files.

## 4. Sync Versions

```bash theme={"dark"}
moda prompts sync
```

Sync uploads changed prompts and writes `.moda/prompts.lock.json` with the server prompt ID, version ID, source path, and content hash.

During development, you can keep the sync loop running:

```bash theme={"dark"}
moda prompts sync --watch
```

## 5. Render at Runtime

<CodeGroup>
  ```typescript Node.js theme={"dark"}
  import { Moda } from "moda-ai";
  import OpenAI from "openai";

  await Moda.init(process.env.MODA_API_KEY!);

  const client = new OpenAI();
  const rendered = Moda.prompt("support.triage").render({
    ticket: { text: userMessage },
  });

  Moda.conversationId = conversationId;
  Moda.userId = userId;

  const response = await client.chat.completions.create({
    model: "gpt-4o",
    messages: rendered.messages,
  });

  await Moda.flush();
  ```

  ```python Python theme={"dark"}
  import moda
  from openai import OpenAI

  moda.init("YOUR_MODA_API_KEY")
  moda.conversation_id = conversation_id
  moda.user_id = user_id

  client = OpenAI()
  rendered = moda.prompt("support.triage").render({
      "ticket": {"text": user_message},
  })

  response = client.chat.completions.create(
      model="gpt-4o",
      messages=rendered["messages"],
  )

  moda.flush()
  ```
</CodeGroup>

## 6. Promote a Label

```bash theme={"dark"}
moda prompts promote support.triage --label=prod --version=pver_abc123
```

Use `dev`, `staging`, and `prod` labels to mark rollout state. Versions stay immutable; labels move.
