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

# Quick Start

> Generate your first AI image in under a minute.

This guide walks you through making your first API request. You will generate an image, poll for the result, and get the output URL.

## Prerequisites

You need an [API key](https://docs.artificialstudio.ai/getting-started/authentication.md). If you do not have one, create it now — it takes 30 seconds.

## 1. Create a generation

Send a `POST` request to `/api/run` with a tool and prompt:

```bash bash theme={null}
curl -X POST https://api.artificialstudio.ai/api/run \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_API_KEY" \
  -d '{
    "tool": "create-image",
    "input": {
      "prompt": "A futuristic city at sunset, cyberpunk style, neon lights"
    }
  }'
```

```javascript JavaScript theme={null}
const response = await fetch('https://api.artificialstudio.ai/api/run', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    tool: 'create-image',
    input: {
      prompt: 'A futuristic city at sunset, cyberpunk style, neon lights'
    }
  })
});

const data = await response.json();
console.log(data.id); // Save this to check status
```

```python Python theme={null}
import requests

response = requests.post(
    'https://api.artificialstudio.ai/api/run',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'YOUR_API_KEY'
    },
    json={
        'tool': 'create-image',
        'input': {
            'prompt': 'A futuristic city at sunset, cyberpunk style, neon lights'
        }
    }
)

data = response.json()
print(data['id'])  # Save this to check status
```

The API returns immediately with a generation ID:

```json theme={null}
{
  "id": "507f1f77bcf86cd799439011",
  "status": "processing",
  "tool": "create-image",
  "createdAt": "2024-01-15T10:30:00.000Z"
}
```

## 2. Poll for the result

Check the generation status every few seconds until it completes:

```bash bash theme={null}
curl https://api.artificialstudio.ai/api/generations/507f1f77bcf86cd799439011 \
  -H "Authorization: YOUR_API_KEY"
```

```javascript JavaScript theme={null}
const poll = async (id) => {
  while (true) {
    const res = await fetch(
      `https://api.artificialstudio.ai/api/generations/${id}`,
      { headers: { 'Authorization': 'YOUR_API_KEY' } }
    );
    const gen = await res.json();

    if (gen.status === 'success') return gen;
    if (gen.status === 'error') throw new Error(gen.error);

    await new Promise(r => setTimeout(r, 2000));
  }
};

const result = await poll(data.id);
console.log(result.output); // URL to your image
```

```python Python theme={null}
import time

def poll(generation_id):
    while True:
        res = requests.get(
            f'https://api.artificialstudio.ai/api/generations/{generation_id}',
            headers={'Authorization': 'YOUR_API_KEY'}
        )
        gen = res.json()

        if gen['status'] == 'success':
            return gen
        if gen['status'] == 'error':
            raise Exception(gen['error'])

        time.sleep(2)

result = poll(data['id'])
print(result['output'])  # URL to your image
```

When the generation completes, you get the output URL:

```json theme={null}
{
  "id": "507f1f77bcf86cd799439011",
  "status": "success",
  "output": "https://files.artificialstudio.ai/generations/abc123.png",
  "thumbnail": "https://files.artificialstudio.ai/thumbnails/abc123.jpg",
  "tool": "create-image",
  "type": "image",
  "createdAt": "2024-01-15T10:30:00.000Z"
}
```

## 3. Use webhooks instead (recommended)

Polling works, but webhooks are better for production. Add a `webhook` URL to your request and the API will `POST` the result to your server when the generation finishes:

```bash theme={null}
curl -X POST https://api.artificialstudio.ai/api/run \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_API_KEY" \
  -d '{
    "tool": "create-image",
    "input": {
      "prompt": "A futuristic city at sunset"
    },
    "webhook": "https://your-server.com/webhook"
  }'
```

See [Webhooks](https://docs.artificialstudio.ai/api/webhook.md) for setup details and best practices.

## Next steps

> [card] [API reference](https://docs.artificialstudio.ai/api/run.md)
>
> Full details on the `/api/run` endpoint.

> [card] [Browse models](https://docs.artificialstudio.ai/image/nano-banana.md)
>
> See all available models and their parameters.

> [card] [Webhooks](https://docs.artificialstudio.ai/api/webhook.md)
>
> Set up real-time notifications for completed generations.

> [card] [List tools](https://docs.artificialstudio.ai/api/tools.md)
>
> Discover all available tools and capabilities.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.