# Prompt and answer

`GET /v1/generation/content` answers the prompt and the answer of one request, where they were
kept.

## Request

Send it with an API key. The one field goes in the address, after `?`. Only what was kept comes
back: a key with storage off keeps nothing, and [Files and storage](/docs/files-and-storage)
says what each kind of request keeps. [Receipt](/docs/reference/generation) answers the same
request's model, tokens and charge.

| Field | Needed | You send |
|---|---|---|
| `id` | yes | the receipt handle the answer carried in its `X-Generation-Id` header |

You read only your own account's requests: any other `id` is a 404. The handle in each sample is
an example of the shape; put the one your answer carried in its place.

A customer tells Souk Bot the picture it made of a kaftan came out wrong. Yacine reads that
request back by its handle to see what was sent and what came out.

```python
import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
GENERATION_ID = "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG"
ADDRESS = "https://opendunes.com/v1/generation/content?id=" + GENERATION_ID

request = urllib.request.Request(
    ADDRESS,
    headers={"Authorization": "Bearer " + API_KEY},
)
with urllib.request.urlopen(request) as response:
    content = json.load(response)["data"]

print(content["output"]["files"])
```

```javascript
const API_KEY = process.env.OPENDUNES_API_KEY;
const GENERATION_ID = "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG";
const BASE_URL = "https://opendunes.com/v1";
const ADDRESS = `${BASE_URL}/generation/content?id=${GENERATION_ID}`;

const response = await fetch(ADDRESS, {
  headers: { Authorization: `Bearer ${API_KEY}` },
});
const { data } = await response.json();

console.log(data.output.files);
```

```go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

const (
	baseURL      = "https://opendunes.com/v1"
	generationID = "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG"
	address      = baseURL + "/generation/content?id=" + generationID
)

func main() {
	apiKey := os.Getenv("OPENDUNES_API_KEY")

	req, err := http.NewRequest("GET", address, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+apiKey)

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	var body struct {
		Data struct {
			Output struct {
				Files []string `json:"files"`
			} `json:"output"`
		} `json:"data"`
	}
	if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
		panic(err)
	}
	fmt.Println(body.Data.Output.Files)
}
```

```bash cURL
GENERATION_ID="gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG"
ADDRESS="https://opendunes.com/v1/generation/content?id=$GENERATION_ID"

curl "$ADDRESS" \
  -H "Authorization: Bearer $OPENDUNES_API_KEY"
```

## Response

`200 OK`.

| Field | Holds |
|---|---|
| `data` | what was kept of the request |
| `input` | the prompt: the text sent, or the list of messages; `null` where it was not kept |
| `output` | what came back |
| `completion` | in `output`: the answer's text, or `null` where it was not kept |
| `reasoning` | in `output`: the thinking the model wrote before it answered, or `null` |
| `files` | in `output`: the `id` of each file the request made and kept, a picture, a voice or a clip, read with `GET /v1/files/{id}` |
| `error` | why the request failed, where it failed and the failure was kept: its `status` and `message`; `null` when it succeeded |

## What it cost

Free. Reading what a request kept is never charged.

## Errors

`error.code` carries the status, and `error.message` says why.

| Status | When |
|---|---|
| 400 | `id` is missing |
| 401 | the key is missing, wrong, disabled or expired |
| 403 | the key answers only from the addresses set on it, and this request came from another |
| 404 | no request of your account carries this handle, or nothing of it was kept |
