Skip to main content
POST
Create a task

Authorizations

Authorization
string
header
required

An API key from the dashboard: afg_live_… or afg_test_….

Headers

idempotency-key
string
Required string length: 1 - 255

Body

application/json
prompt
string
required
Required string length: 1 - 2000
Example:

"best running shoes for flat feet"

model
string
required
Required string length: 1 - 64
Example:

"chatgpt"

country
string
required
Pattern: ^[A-Z]{2}$
Example:

"US"

language
string
required
Required string length: 2 - 10
Example:

"en"

enrichments
string[]

Accepted for later. V1 computes every enrichment: entities, sentiment, sources, fan-outs, shopping, ads.

Maximum array length: 10
webhookUrl
string

https only. Gets task.completed or task.failed for this task.

Maximum string length: 2048
metadata
object

Your own labels, returned as given.

Example:

Response

Replayed: the task of this Idempotency-Key

id
string
required
status
enum<string>
required
Available options:
queued,
processing,
completed,
failed
mode
enum<string>
required
Available options:
live,
test
prompt
string
required
model
string
required
country
string
required
language
string
required
enrichments
string[]
required
metadata
object
required
webhookUrl
string | null
required
costMicros
integer
required

What the task was charged, in micro-dollars: 13000 is $0.013. 0 for a test key.

refunded
boolean
required
apiKeyId
string | null
required
createdAt
string
required
startedAt
string | null
required
completedAt
string | null
required
failedAt
string | null
required
error
object | null
required
resultExpiresAt
string | null
required

When the result stops being readable: 7 days after completion. Null until the task completes.

result
object | null
required

Once completed, on GET /v1/tasks/{taskId} only, for 7 days (resultExpiresAt). Null after that; the task stays.