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 keyAPI keyThe key you create and send with every request that calls a model.More on API keys →. 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
says what each kind of request keeps. Receipt 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.
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"])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 |
Last modified on