Flux Professional Images
Profesionalno generiranje slika vrhunske kvalitete i detalja.
✓ Slike do 2K rezolucije
✓ Fotorealistično
✓ Kontrola stila
✓ Brzo generiranje
Autentifikacija
Za pristup usluzi Flux Pro putem Doitong API-ja, koristite svoj Doitong API ključ. Uključite ga u GraphQL mutaciju ili zaglavlja REST API-ja.
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
Brzi početak
Započnite s radom u usluzi Flux Pro API u samo nekoliko minuta. Slijedite ove jednostavne korake za generiranje svog prvog text to image.
1. korak: Preuzmite svoj API ključ
Registrirajte se za Doitong račun i idite na svoju nadzornu ploču kako biste generirali API ključ.
2. korak: Pošaljite svoj prvi zahtjev
Upotrijebite jedan od primjera koda u nastavku za svoj prvi API poziv.
curl -X POST https://api.doitong.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata creditCost } }",
"variables": {
"input": {
"type": "IMAGE",
"provider": "flux-pro",
"input": {
"text": "A futuristic city with flying cars and neon lights"
},
"options": {
"width": 1024,
"height": 1024
}
}
}
}'
const response = await fetch('https://api.doitong.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
query: `
mutation GenerateImage($input: ImageGenerationInput!) {
generateImage(input: $input) {
id
url
width
height
}
}
`,
variables: {
input: {
service: 'flux-pro',
prompt: 'A futuristic city with flying cars and neon lights',
width: 1024,
height: 1024
}
}
})
});
const data = await response.json();
console.log('Image:', data.data.generateImage);
import requests
import json
url = "https://api.doitong.com/graphql"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
query = """
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
}
}
"""
variables = {
"input": {
"type": "IMAGE",
"provider": "flux-pro",
"input": {
"text": "A futuristic city with flying cars and neon lights"
},
"options": {
"width": 1024,
"height": 1024
}
}
}
response = requests.post(url, json={
"query": query,
"variables": variables
}, headers=headers)
data = response.json()
print("Result:", data["data"]["generate"])
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
createdAt
}
}
# Variables
{
"input": {
"type": "IMAGE",
"provider": "flux-pro",
"input": {
"text": "A futuristic city with flying cars and neon lights"
},
"options": {
"width": 1024,
"height": 1024,
"version": "flux-pro-1.1",
"quality": "high"
}
}
}
Cijene
Flux Pro API koristi model naplate temeljen na kreditima. Krediti se troše ovisno o složenosti i trajanju generiranog sadržaja.
| Značajka | Krediti | Opis |
|---|---|---|
| Standardna rezolucija | 10-20 Krediti | 512x512 do 1024x1024 piksela |
| Visoka rezolucija | 30-50 Krediti | 2048x2048 piksela i više |
API krajnje točke
Flux Pro API je dostupan putem naše objedinjene GraphQL krajnje točke.
GraphQL krajnja točka
POST https://api.doitong.com/graphql
REST krajnja točka
POST https://api.doitong.com/v1/text_to_image
Parametri
Dostupni parametri za Flux Pro API zahtjeve:
| Parametar | Vrsta | Obavezno | Opis |
|---|---|---|---|
service |
String | Yes | Identifikator usluge: "flux-pro" |
prompt |
String | Yes | Tekstualni opis onoga što želite generirati |
width |
Integer | No | Širina slike u pikselima (zadano: 1024) |
height |
Integer | No | Visina slike u pikselima (zadano: 1024) |
version |
String | No | Model version: "flux-pro", "flux-pro-1.1" |
webhookUrl |
String | No | URL za primanje obavijesti o završetku |
Format odgovora
Svi API odgovori slijede dosljedan format:
Uspješan odgovor
{
"data": {
"generateimage": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Završen odgovor
{
"data": {
"generateimage": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.jpg",
"duration": null,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Obrada pogrešaka
API koristi standardne HTTP statusne kodove i vraća detaljne poruke o pogreškama.
Uobičajeni kodovi pogrešaka
| Statusni kod | Vrsta pogreške | Opis |
|---|---|---|
| 400 | Bad Request | Invalid parameters or malformed request |
| 401 | Unauthorized | Missing or invalid API key |
| 402 | Payment Required | Insufficient credits |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error, please retry |
Format odgovora o pogrešci
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhooks
Primajte obavijesti u stvarnom vremenu kada generiranje vašeg text to image završi.
Postavljanje webhookova
Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.
Webhook podaci (payload)
{
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.jpg",
"service": "flux-pro",
"createdAt": "2024-01-01T00:00:00Z",
"completedAt": "2024-01-01T00:01:00Z",
"metadata": {
"duration": null,
"width": 1920,
"height": 1080
}
}
Sigurnost webhookova
Svi zahtjevi webhooka uključuju zaglavlje s potpisom radi provjere:
X-Doitong-Signature: sha256=abc123...
Ograničenja učestalosti (Rate Limits)
Kako bi se osiguralo pošteno korištenje i stabilnost sustava, primjenjuju se sljedeća ograničenja:
| Plan | Zahtjeva/minuti | Istovremeni zadaci | Dnevno ograničenje |
|---|---|---|---|
| Besplatno | 10 | 1 | 100 |
| Starter | 30 | 3 | 1,000 |
| Pro | 60 | 10 | 10,000 |
| Enterprise | Prilagođeno | Prilagođeno | Neograničeno |
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
Najbolje prakse
1. Optimizirajte svoje upite
Pišite jasne i opisne upite za najbolje rezultate:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. Upravljajte asinkronom obradom
Generiranje je asinkrono. Implementirajte ispravno prozivanje (polling) ili webhooks:
// Polling example
async function pollStatus(jobId) {
let status = 'processing';
while (status === 'processing') {
await sleep(2000); // Wait 2 seconds
const result = await checkJobStatus(jobId);
status = result.status;
}
return result;
}
3. Oporavak od pogrešaka
Implementirajte logiku ponovnog pokušaja s eksponencijalnim odmakom:
async function retryWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await sleep(Math.pow(2, i) * 1000);
}
}
}
4. Pratite potrošnju kredita
Pratite potrošnju kredita kako biste izbjegli prekide u radu:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
Spremni za početak?
Pridružite se tisućama programera koji koriste Flux Pro API za stvaranje nevjerojatnog sadržaja