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

# Generate images from a local runtime.

OpenAI-compatible image generation against an installed local runtime that serves the image modality. Pass a `model` id from `GET /v1/models`. 

` POST /v1/images/generations `

Generate images from a local runtime.

OpenAI-compatible image generation against an installed local runtime
that serves the image modality. Pass a `model` id from `GET /v1/models`.


## Servers

- ` http://127.0.0.1:8831 ` — Default local host-agent listener.

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` LocalBearer `: ` http `

  - HTTP scheme: ` bearer ` (b3iq_local)

  - Local API key with local chat scope.

### Alternative 2

- ` LocalAPIKeyHeader `: ` apiKey `

  - Credential: ` X-B3IQ-API-Key ` in ` header `

  - Alternate header for local API keys.

### Alternative 3

- ` SetupBearer `: ` http `

  - HTTP scheme: ` bearer `

  - Setup token before operator configuration, or an authenticated operator session outside this spec.

### Alternative 4

- ` RouterSignedHeaders `: ` apiKey `

  - Credential: ` X-B3IQ-Router-Signature ` in ` header `

  - Router HMAC signature headers are used only by B3IQ router dispatch.

## Request body (required)

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` model `, ` prompt `

  - ` model `: type ` string `

  - ` prompt `: type ` string `

  - ` n `: type ` integer `

    - minimum: ` 1 `

  - ` size `: type ` string ` — Requested image size, e.g. 512x512.

  - ` steps `: type ` integer `

  - ` response_format `: type ` string `

  - ` runtime_id `: type ` string `

## Responses

### ` 200 ` — Generated images (base64-encoded by default).

Content type: ` application/json `

- ` value `: type ` object `

  - ` created `: type ` integer `

  - ` data `: type ` array `

    - ` array item `: type ` object `

      - ` b64_json `: type ` string `

### ` default ` — B3IQ-native problem response.

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` error `

  - ` error `: type ` object `

    - Required fields: ` status `, ` title `, ` detail `

    - ` status `: type ` integer `

    - ` title `: type ` string `

    - ` detail `: type ` string `

    - ` code `: type ` string ` — Stable B3IQ code when present. See docs/error-codes.md.

## Request examples

### cURL

```curl
curl -X POST 'http://127.0.0.1:8831/v1/images/generations' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "string",
  "prompt": "string",
  "n": 1,
  "size": "string",
  "steps": 0,
  "response_format": "string",
  "runtime_id": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('http://127.0.0.1:8831/v1/images/generations', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "model": "string",
    "prompt": "string",
    "n": 1,
    "size": "string",
    "steps": 0,
    "response_format": "string",
    "runtime_id": "string"
  })
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('http://127.0.0.1:8831/v1/images/generations', headers=headers, json={
  "model": "string",
  "prompt": "string",
  "n": 1,
  "size": "string",
  "steps": 0,
  "response_format": "string",
  "runtime_id": "string"
})
print(response.json())
```