Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tokmodel.com/llms.txt

Use this file to discover all available pages before exploring further.

TokModel provides three image endpoints that cover the most common image tasks: generating a new image from a text prompt, editing an existing image using a mask and a prompt, and producing variations of an existing image. All three endpoints return one or more image URLs (or Base64-encoded image data) in a data array. Select the tab below for the endpoint you need.

POST /v1/images/generations

Generate one or more images from a text description. The model creates the image from scratch based on your prompt.

Request parameters

prompt
string
required
A text description of the image you want to generate. More detailed prompts generally produce better results.
model
string
The image generation model to use. Defaults to the provider’s standard model if omitted. Use the list models endpoint for available options.
n
integer
default:"1"
The number of images to generate. Each image is returned as a separate item in the data array.
size
string
default:"1024x1024"
The dimensions of the generated images. Supported values depend on the model. Common options include "256x256", "512x512", and "1024x1024".
response_format
string
default:"url"
How to return the generated image. Use "url" for a temporary hosted URL or "b64_json" for a Base64-encoded string.

Example

curl https://tokmodel.com/v1/images/generations \
  --request POST \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "openai/dall-e-3",
    "prompt": "A photorealistic image of a red panda sitting on a mossy log in a rainforest",
    "n": 1,
    "size": "1024x1024",
    "response_format": "url"
  }'

Response

{
  "created": 1716470400,
  "data": [
    {
      "url": "https://cdn.tokmodel.com/images/generated/abc123.png"
    }
  ]
}