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
Erzeuge ein Standardbild als Base64 mit einem 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."
}
]
}Erzeuge mit
Der Pfadwert
POST /openai/{region}/v1/images/generations ein Standardbild. Sende einen Prompt und ein Bildmodell aus deinem Workspace. Die Antwort liefert das Bild als b64_json.
Die Anfrage nutzt denselben Completion-API-Scope wie OpenAI Chat Completions und OpenAI Responses. Chat-Tools, Workflow-Nodes und imageGeneration in der Agent API sind eigene Oberflächen.
Bevor du startest
- API-Key: Erstelle einen persönlichen API-Key oder frage deinen Workspace-Admin nach einem Workspace-API-Key mit dem Scope Completion API.
Basis-URL
https://api.langdock.com/openai/{region}/v1/images/generations
Dedicated DeploymentsErsetze
api.langdock.com durch <your-deployment-url>/api/public in allen Anfragen.{region} muss eu oder us sein. Dieser Endpunkt akzeptiert kein global.
Parameter
Der Request-Body ist ein striktes Objekt. Zusätzliche Felder führen zu400.
| Parameter | Beschreibung |
|---|---|
model | Pflicht. Die Bildmodell-ID aus deinem Workspace. Sichtbare Bildmodelle in der Region der Anfrage mit einem API-Deployment werden akzeptiert. GET /openai/{region}/v1/models listet Chat-Modelle, keine Bildmodelle. Ein unbekanntes Modell liefert 400 mit den Bildmodell-IDs dieser Region. Gibt es in der Region keines, sagt das der 400. |
prompt | Pflicht. Die Bildbeschreibung. |
n | Optional. Wenn du den Wert sendest, muss er 1 sein. |
size | Optional. auto (Standard), 1024x1024, 1536x1024 oder 1024x1536. auto und 1024x1024 entsprechen quadratisch, 1536x1024 quer und 1024x1536 hochkant. |
quality | Optional. auto, low, medium oder high. Langdock reicht den Wert an das Bildmodell weiter. Nicht jedes Bildmodell nutzt ihn. |
response_format | Optional. Nur b64_json. |
user | Optional. Wird für OpenAI-Kompatibilität akzeptiert. |
Antwort
Eine erfolgreiche Antwort ist JSON mitcreated und data. data enthält ein Objekt mit b64_json und, wenn das Modell einen liefert, revised_prompt. Der HTTP-Body enthält kein usage-Objekt. Der Response-Header ld-model-id wiederholt die Modell-ID.
Die Generierung bricht nach 60 Sekunden ab. Ein Timeout liefert 504 mit The model did not respond in time. Please retry.
Unterschiede zur OpenAI API
- Ein Bild pro Anfrage. Ein
n-Wert ungleich1wird abgelehnt. response_formatist nurb64_json. URL-Ausgabe wird nicht unterstützt.- HD- bzw. High-Resolution-Generierung wird nicht unterstützt.
- Es gibt keinen öffentlichen
/v1/images/edits-Endpunkt.
OpenAI-Python-Bibliothek verwenden
Lege Langdock als Basis-URL fest und verwendeimages.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="Ein Leuchtturm in der Dämmerung",
size="1024x1024",
response_format="b64_json",
)
print(image.data[0].b64_json)
Rate Limits
Die Standardlimits sind 500 RPM (Anfragen pro Minute) und 150.000 TPM (Tokens pro Minute).- RPM gilt pro Workspace, Modell und API-Key.
- TPM teilen sich alle API-Keys, die dasselbe Modell in einem Workspace nutzen.
- In Dedicated Deployments können Admins unter Einstellungen > Workspace > Produkte > API eigene Limits je Modell festlegen.
429 Too Many Requests. Erfolgreiche Antworten und Antworten mit Rate-Limit-Fehler enthalten die Response-Header x-ratelimit-limit-requests, x-ratelimit-limit-tokens, x-ratelimit-remaining-requests und x-ratelimit-remaining-tokens.
Die Nutzung persönlicher API-Keys zählt zusammen mit Chat- und Agenten-Nutzung zum effektiven persönlichen Budget des Mitglieds und zum Workspace-Ausgabenlimit. Die Nutzung von Workspace-API-Keys zählt zum API-Spend-Limit des Workspace. Bildgenerierungs-Aufrufe werden als Image-Generation-Nutzung abgerechnet. Siehe Persönliche API-Keys und Preise.
Browser- und CORS-Integrationen werden nicht unterstützt. Bewahre API-Keys serverseitig auf und rufe den Endpunkt über einen Server, eine CLI oder ein lokales Entwicklungstool auf. Weitere Informationen findest du in den Best Practices für API-Keys.
Autorisierungen
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Pfadparameter
The region of the API to use. Must be eu or us.
Verfügbare Optionen:
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.
Verfügbare Optionen:
1 Output size. auto and 1024x1024 map to square, 1536x1024 to landscape, and 1024x1536 to portrait.
Verfügbare Optionen:
auto, 1024x1024, 1536x1024, 1024x1536 Quality hint forwarded to the image model. Not every image model uses it.
Verfügbare Optionen:
auto, low, medium, high Response format. Only b64_json is supported.
Verfügbare Optionen:
b64_json Optional end-user identifier. Accepted for OpenAI compatibility.
War diese Seite hilfreich?