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

# Create Prompt

> Create a new prompt

```python theme={null}
prompt = client.prompts.create(options)
# Async
prompt = await client.prompts.acreate(options)
```

Create a new prompt with the specified content. The prompt is created at version 1.

## Parameters

Pass a `CreatePromptOptions` object:

| Parameter           | Type                  | Required | Description                                                          |
| ------------------- | --------------------- | -------- | -------------------------------------------------------------------- |
| `name`              | `str`                 | Yes      | Display name for the prompt                                          |
| `content`           | `list[PromptMessage]` | Yes      | Array of messages                                                    |
| `slug`              | `str`                 | No       | URL-friendly identifier (auto-generated from name if omitted)        |
| `model`             | `str`                 | No       | Default model (e.g., `gpt-4o`)                                       |
| `provider`          | `LLMProvider`         | No       | Provider (`"openai"`, `"anthropic"`, `"google"`, `"amazon_bedrock"`) |
| `description`       | `str`                 | No       | Description of the prompt                                            |
| `temperature`       | `float`               | No       | Default temperature                                                  |
| `max_output_tokens` | `int`                 | No       | Default max output tokens                                            |
| `top_p`             | `float`               | No       | Default top-p value                                                  |
| `stop_sequences`    | `list[str]`           | No       | Default stop sequences                                               |

### PromptMessage

| Field     | Type  | Required | Description                                   |
| --------- | ----- | -------- | --------------------------------------------- |
| `id`      | `str` | Yes      | Unique message identifier                     |
| `role`    | `str` | Yes      | `system`, `developer`, `user`, or `assistant` |
| `content` | `str` | Yes      | Message content (supports `{{variables}}`)    |

## Response

Returns the created `Prompt` object.

## Examples

### Basic Usage

```python theme={null}
from tracia import CreatePromptOptions, PromptMessage

prompt = client.prompts.create(CreatePromptOptions(
    name="Welcome Email",
    slug="welcome-email",
    content=[
        PromptMessage(id="msg_1", role="system", content="You are a helpful assistant."),
        PromptMessage(id="msg_2", role="user", content="Write a welcome email for {{name}}."),
    ],
))

print(prompt.slug)  # "welcome-email"
```

### With Description and Options

```python theme={null}
prompt = client.prompts.create(CreatePromptOptions(
    name="Welcome Email",
    slug="onboarding-welcome",
    description="Sent to new users after signup",
    model="gpt-4o",
    provider="openai",
    temperature=0.7,
    content=[
        PromptMessage(id="msg_1", role="system", content="You write professional emails."),
        PromptMessage(id="msg_2", role="user", content="Write a welcome email for {{name}} at {{company}}."),
    ],
))
```

### Multi-Turn Conversation

```python theme={null}
prompt = client.prompts.create(CreatePromptOptions(
    name="Code Review Assistant",
    slug="code-review",
    model="claude-sonnet-4-20250514",
    provider="anthropic",
    content=[
        PromptMessage(
            id="msg_1",
            role="system",
            content="You are a senior software engineer conducting code reviews.",
        ),
        PromptMessage(
            id="msg_2",
            role="user",
            content="Please review this {{language}} code:\n\n{{code}}",
        ),
        PromptMessage(
            id="msg_3",
            role="assistant",
            content="I'll review this code for correctness, performance, and best practices.",
        ),
        PromptMessage(
            id="msg_4",
            role="user",
            content="Focus especially on {{focus_area}}.",
        ),
    ],
))
```

<Tip>
  Slugs must be lowercase with hyphens only (e.g., `welcome-email`).
</Tip>

## Error Handling

```python theme={null}
from tracia import TraciaError, TraciaErrorCode

try:
    prompt = client.prompts.create(CreatePromptOptions(
        name="Welcome Email",
        slug="welcome-email",
        content=[...],
    ))
except TraciaError as error:
    if error.code == TraciaErrorCode.CONFLICT:
        print("A prompt with this slug already exists")
    elif error.code == TraciaErrorCode.INVALID_REQUEST:
        print(f"Invalid request: {error.message}")
```
