> For the complete documentation index, see [llms.txt](https://dar-open-network.gitbook.io/developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dar-open-network.gitbook.io/developers/deai/ainft-framework/generate-a-story-for-an-nft-agent.md).

# Generate a Story for an NFT Agent

Generate unique narratives based on an agent's characteristics and a chosen theme.

#### **Example**:

* **Theme**: "Space Adventure"
* **Generated Story**: *"Agent Astro embarked on a thrilling journey across the galaxy, encountering alien species and uncovering ancient treasures."*

#### **Endpoint**:

```bash
/agent/${agentId}/story
```

#### Request Format:

* **Method**: `POST`
* **Headers**:
  * `Content-Type`: `application/json`
* **Body**:

  ```json
  {
    "theme": "Your theme here"
  }

  ```

#### Response Format:

* **Structure**:

  ```json
  {
    "data": {
      "story": "Generated story content"
    }
  }

  ```

#### Example Code:

```jsx
async function generateAgentStory(agentId, theme) {
    const response = await fetch(`https://api.example.com/agent/${agentId}/story`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ theme })
    });

    const data = await response.json();
    return data.data.story;
}

// Usage:
generateAgentStory("agent123", "space_adventure")
    .then(story => console.log(story));

```
