Flux Professional Images
Giniúint íomhánna gairmiúil le sárchaighdeán agus mionsonraí den scoth.
✓ Íomhánna suas le 2K
✓ Fóta-réalaíoch
✓ Rialú stíle
✓ Giniúint thapa
Fíordheimhniú
Chun teacht ar Flux Pro trí API Doitong, úsáid d'eochair API Doitong. Cuir san áireamh í i mutation GraphQL nó i gceanntásca an API REST.
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
Treoir Thapa
Cuir tús le Flux Pro API laistigh de chúpla nóiméad. Lean na céimeanna simplí seo chun do chéad text to image a ghiniúint.
Céim 1: Faigh d'Eochair API
Cláraigh le haghaidh cuntas Doitong agus téigh chuig do phainéal rialaithe chun eochair API a ghiniúint.
Céim 2: Déan do Chéad Iarratas
Úsáid ceann de na samplaí cóid thíos chun do chéad ghlao API a dhéanamh.
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"
}
}
}
Praghsáil
Úsáideann Flux Pro API múnla praghsála bunaithe ar chreidmheasanna. Ídítear creidmheasanna bunaithe ar chastacht agus ar fhad an ábhair a ghintear.
| Gné | Creidmheasanna | Cur Síos |
|---|---|---|
| Taifeach Caighdeánach | 10-20 Creidmheasanna | 512x512 go 1024x1024 picteilín |
| Ardtaifeach | 30-50 Creidmheasanna | 2048x2048 picteilín agus os a chionn |
Críochphointí API
Tá Flux Pro API ar fáil trínár gcríochphointe aontaithe GraphQL.
Críochphointe GraphQL
POST https://api.doitong.com/graphql
Críochphointe REST
POST https://api.doitong.com/v1/text_to_image
Paraiméadair
Paraiméadair atá ar fáil d'iarratais Flux Pro API:
| Paraiméadar | Cineál | Riachtanach | Cur Síos |
|---|---|---|---|
service |
Teaghrán | Yes | Aitheantóir seirbhíse: "flux-pro" |
prompt |
Teaghrán | Yes | Tuairisc téacs ar cad ba mhaith leat a ghiniúint |
width |
Slánuimhir | No | Leithead na híomhá i bpicteilíní (réamhshocrú: 1024) |
height |
Slánuimhir | No | Airde na híomhá i bpicteilíní (réamhshocrú: 1024) |
version |
Teaghrán | No | Model version: "flux-pro", "flux-pro-1.1" |
webhookUrl |
Teaghrán | No | URL chun fógraí críochnaithe a fháil |
Formáid an Fhreagra
Leanann gach freagra API formáid chomhsheasmhach:
Freagra rathúil
{
"data": {
"generateimage": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Freagra críochnaithe
{
"data": {
"generateimage": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.jpg",
"duration": null,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Láimhseáil Earráidí
Úsáideann an API cóid stádais HTTP chaighdeánacha agus seolann sé teachtaireachtaí earráide mionsonraithe ar ais.
Cóid Earráide Choitianta
| Cód Stádais | Cineál Earráide | Cur Síos |
|---|---|---|
| 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 |
Formáid an Fhreagra Earráide
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhooks
Faigh fógraí fíor-ama nuair a bhíonn do ghiniúint text to image críochnaithe.
Webhooks a Chumrú
Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.
Lastas Pá Webhook
{
"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
}
}
Slándáil Webhook
Cuimsíonn gach iarratas webhook ceanntásc sínithe le haghaidh fíoraithe:
X-Doitong-Signature: sha256=abc123...
Teorainneacha Ráta
Chun úsáid chothrom agus cobhsaíocht an chórais a chinntiú, tá na teorainneacha ráta seo a leanas i bhfeidhm:
| Plean | Iarratais/Nóiméad | Jabanna Comhthráthacha | Teorainn laethúil |
|---|---|---|---|
| Saor in aisce | 10 | 1 | 100 |
| Tosaitheoir | 30 | 3 | 1,000 |
| Pro | 60 | 10 | 10,000 |
| Fiontar | Saincheaptha | Saincheaptha | Gan teorainn |
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
Dea-chleachtais
1. Optamaigh do chuid Prasanna
Scríobh prasanna soiléire tuairisciúla chun na torthaí is fearr a fháil:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. Láimhseáil Próiseáil Asincrónach
Is próiseas asincrónach é an ghiniúint. Cuir vótaíocht chuí nó webhooks i bhfeidhm:
// 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. Téarnamh ó Earráidí
Cuir loighic atriail i bhfeidhm le haischéimniú easpónantúil:
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. Monatóireacht ar Úsáid Creidmheasa
Coinnigh súil ar do chuid creidmheasanna chun briseadh sa tseirbhís a sheachaint:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
An bhfuil tú réidh le tosú?
Bí i dteannta na mílte forbróirí atá ag úsáid Flux Pro API chun ábhar iontach a chruthú