Generates one standard image as base64.
curl --request POST \
--url https://api.langdock.com/openai/{region}/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "your-image-model-id",
"prompt": "A lighthouse at dusk",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}
'import requests
url = "https://api.langdock.com/openai/{region}/v1/images/generations"
payload = {
"model": "your-image-model-id",
"prompt": "A lighthouse at dusk",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'your-image-model-id',
prompt: 'A lighthouse at dusk',
n: 1,
size: '1024x1024',
response_format: 'b64_json'
})
};
fetch('https://api.langdock.com/openai/{region}/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.langdock.com/openai/{region}/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'your-image-model-id',
'prompt' => 'A lighthouse at dusk',
'n' => 1,
'size' => '1024x1024',
'response_format' => 'b64_json'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.langdock.com/openai/{region}/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"your-image-model-id\",\n \"prompt\": \"A lighthouse at dusk\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.langdock.com/openai/{region}/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"your-image-model-id\",\n \"prompt\": \"A lighthouse at dusk\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/openai/{region}/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"your-image-model-id\",\n \"prompt\": \"A lighthouse at dusk\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1721722200,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
"revised_prompt": "A coastal lighthouse at dusk, warm lantern light."
}
]
}Completion API
OpenAI Image Generations
Generate one standard image as base64 with a Completion API key.
POST
/
openai
/
{region}
/
v1
/
images
/
generations
Generates one standard image as base64.
curl --request POST \
--url https://api.langdock.com/openai/{region}/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "your-image-model-id",
"prompt": "A lighthouse at dusk",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}
'import requests
url = "https://api.langdock.com/openai/{region}/v1/images/generations"
payload = {
"model": "your-image-model-id",
"prompt": "A lighthouse at dusk",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'your-image-model-id',
prompt: 'A lighthouse at dusk',
n: 1,
size: '1024x1024',
response_format: 'b64_json'
})
};
fetch('https://api.langdock.com/openai/{region}/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.langdock.com/openai/{region}/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'your-image-model-id',
'prompt' => 'A lighthouse at dusk',
'n' => 1,
'size' => '1024x1024',
'response_format' => 'b64_json'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.langdock.com/openai/{region}/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"your-image-model-id\",\n \"prompt\": \"A lighthouse at dusk\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.langdock.com/openai/{region}/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"your-image-model-id\",\n \"prompt\": \"A lighthouse at dusk\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/openai/{region}/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"your-image-model-id\",\n \"prompt\": \"A lighthouse at dusk\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"response_format\": \"b64_json\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1721722200,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
"revised_prompt": "A coastal lighthouse at dusk, warm lantern light."
}
]
}Generate one standard image with
The
POST /openai/{region}/v1/images/generations. Send a prompt and an image model from your workspace. The response returns the image as b64_json.
The request uses the same Completion API scope as OpenAI Chat Completions and OpenAI Responses. Chat tools, workflow nodes, and Agent API imageGeneration are separate surfaces.
Before You Start
- API key: Create a personal API key or ask your workspace admin for a workspace API key with the Completion API scope.
Base URL
https://api.langdock.com/openai/{region}/v1/images/generations
Dedicated deploymentsReplace
api.langdock.com with <your-deployment-url>/api/public in all requests.{region} path value must be eu or us. This route does not accept global.
Parameters
The request body is a strict object. Extra fields return400.
| Parameter | Description |
|---|---|
model | Required. The image generation model ID from your workspace. Visible image models in the request region with an API-available deployment are accepted. GET /openai/{region}/v1/models lists chat models, not image models. An unknown model returns 400 with the image model IDs available in that region. If the region has none, the 400 says so. |
prompt | Required. The image description. |
n | Optional. Must be 1 if you send it. |
size | Optional. auto (default), 1024x1024, 1536x1024, or 1024x1536. auto and 1024x1024 map to square, 1536x1024 to landscape, and 1024x1536 to portrait. |
quality | Optional. auto, low, medium, or high. Langdock forwards the value to the image model. Not every image model uses it. |
response_format | Optional. b64_json only. |
user | Optional. Accepted for OpenAI compatibility. |
Response
A successful response is JSON withcreated and data. data contains one object with b64_json and, when the model returns one, revised_prompt. The HTTP body has no usage object. The ld-model-id response header repeats the model ID.
Generation times out after 60 seconds. A timeout returns 504 with The model did not respond in time. Please retry.
Differences from the OpenAI API
- One image per request.
nother than1is rejected. response_formatisb64_jsononly. URL output is not supported.- HD / high-resolution generation is not supported.
- There is no public
/v1/images/editsroute.
Using the OpenAI Python library
Set Langdock as the base URL and callimages.generate:
from openai import OpenAI
client = OpenAI(
base_url="https://api.langdock.com/openai/eu/v1",
api_key="<YOUR_LANGDOCK_API_KEY>",
)
image = client.images.generate(
model="your-image-model-id",
prompt="A lighthouse at dusk",
size="1024x1024",
response_format="b64_json",
)
print(image.data[0].b64_json)
Rate limits
The default limits are 500 RPM (requests per minute) and 150,000 TPM (tokens per minute).- RPM is enforced per workspace, model, and API key.
- TPM is shared by all API keys using the same model in a workspace.
- On dedicated deployments, admins can configure custom limits per model in Settings > Workspace > Products > API.
429 Too Many Requests. Successful and rate-limited responses include x-ratelimit-limit-requests, x-ratelimit-limit-tokens, x-ratelimit-remaining-requests, and x-ratelimit-remaining-tokens.
Personal API key usage counts toward the member’s effective personal budget and the workspace spend limit together with chat and agent usage. Workspace API key usage counts toward the workspace API spend limit. Image generation calls are billed as image generation usage. See Personal API keys and Pricing.
Browser and CORS integrations are not supported. Keep API keys server-side and call the endpoint from a server, CLI, or local development tool. See API Key Best Practices.
Authorizations
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Path Parameters
The region of the API to use. Must be eu or us.
Available options:
eu, us Body
application/json
Image generation model ID from your workspace. GET /openai/{region}/v1/models lists chat models, not image models.
Minimum string length:
1The image description.
Minimum string length:
1Number of images. Only 1 is supported.
Available options:
1 Output size. auto and 1024x1024 map to square, 1536x1024 to landscape, and 1024x1536 to portrait.
Available options:
auto, 1024x1024, 1536x1024, 1024x1536 Quality hint forwarded to the image model. Not every image model uses it.
Available options:
auto, low, medium, high Response format. Only b64_json is supported.
Available options:
b64_json Optional end-user identifier. Accepted for OpenAI compatibility.
Was this page helpful?