Delweddau Proffesiynol Flux

Cynhyrchu delweddau proffesiynol gydag ansawdd a manylion rhagorol.

✓ Delweddau hyd at 2K

✓ Ffotorealistig

✓ Rheoli arddull

✓ Cynhyrchu cyflym

Dilysu

I gael mynediad i Flux Pro drwy API Doitong, defnyddiwch eich allwedd API Doitong. Cynhwyswch hi ym mhennynnau'r mwtaniad GraphQL neu'r REST API.

Pwysig: Cadwch eich allwedd API Doitong yn ddiogel a pheidiwch byth â'i datgelu mewn cod ochr-cleient. Gwnewch alwadau API o'ch gweinydd cefn bob amser.
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

// REST Header
"X-API-Key": "YOUR_API_KEY"

Cychwyn Cyflym

Dechreuwch ddefnyddio Flux Pro API mewn ychydig funudau yn unig. Dilynwch y camau syml hyn i gynhyrchu eich text to image cyntaf.

Cam 1: Cael eich Allwedd API

Cofrestrwch am gyfrif Doitong ac ewch i'ch dangosfwrdd i gynhyrchu allwedd API.

Cam 2: Gwneud eich Cais Cyntaf

Defnyddiwch un o'r enghreifftiau cod isod i wneud eich galwad API gyntaf.

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"
    }
  }
}

Prisio

Mae Flux Pro API yn defnyddio model prisio sy'n seiliedig ar gredydau. Defnyddir credydau yn ôl cymhlethdod a hyd y cynnwys a gynhyrchir.

Nodwedd Credydau Disgrifiad
Cydraniad Safonol 10-20 Credydau 512x512 i 1024x1024 picsel
Cydraniad Uchel 30-50 Credydau 2048x2048 picsel ac uwch

Pwyntiau Terfyn API

Mae Flux Pro API ar gael drwy ein pwynt terfyn GraphQL unedig.

Pwynt Terfyn GraphQL

POST https://api.doitong.com/graphql

Pwynt Terfyn REST

POST https://api.doitong.com/v1/text_to_image

Paramedrau

Paramedrau sydd ar gael ar gyfer ceisiadau Flux Pro API:

Paramedr Math Gofynnol Disgrifiad
service Llinyn Yes Dynodwr gwasanaeth: "flux-pro"
prompt Llinyn Yes Disgrifiad testun o beth i'w gynhyrchu
width Cyfanrif No Lled y ddelwedd mewn picseli (rhagosodiad: 1024)
height Cyfanrif No Uchder y ddelwedd mewn picseli (rhagosodiad: 1024)
version Llinyn No Model version: "flux-pro", "flux-pro-1.1"
webhookUrl Llinyn No URL i dderbyn hysbysiadau cwblhau

Fformat yr Ymateb

Mae holl ymatebion yr API yn dilyn fformat cyson:

Ymateb Llwyddiannus

{
  "data": {
    "generateimage": {
      "id": "abc123xyz",
      "status": "processing",
      "url": null,
      "webhookUrl": "https://your-webhook.com/callback",
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Ymateb Wedi'i Gwblhau

{
  "data": {
    "generateimage": {
      "id": "abc123xyz",
      "status": "completed",
      "url": "https://cdn.doitong.com/outputs/abc123xyz.jpg",
      "duration": null,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Trin Gwallau

Mae'r API yn defnyddio codau statws HTTP safonol ac yn dychwelyd negeseuon gwall manwl.

Codau Gwall Cyffredin

Cod Statws Math o Wall Disgrifiad
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

Fformat Ymateb Gwall

{
  "errors": [
    {
      "message": "Insufficient credits for this operation",
      "extensions": {
        "code": "INSUFFICIENT_CREDITS",
        "creditsRequired": 100,
        "creditsAvailable": 50
      }
    }
  ]
}

Webhooks

Derbyniwch hysbysiadau amser-real pan fydd eich text to image wedi'i gynhyrchu.

Ffurfweddu Webhooks

Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.

Llwyth Cyflog 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
  }
}

Diogelwch Webhook

Mae pob cais webhook yn cynnwys pennyn llofnod ar gyfer dilysu:

X-Doitong-Signature: sha256=abc123...

Terfynau Cyfradd

Er mwyn sicrhau defnydd teg a sefydlogrwydd y system, mae'r terfynau cyfradd canlynol yn berthnasol:

Cynllun Ceisiadau/Munud Tasgau Cydredol Terfyn Dyddiol
Am Ddim 10 1 100
Dechreuwr 30 3 1,000
Pro 60 10 10,000
Menter Personol Personol Diderfyn
Pennynnau Terfyn Cyfradd: Gwiriwch bennynnau'r ymateb am statws y terfyn cyfredol:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

Arferion Gorau

1. Optimeiddio eich Anogwyr

Ysgrifennwch anogwyr clir a disgrifiadol i gael y canlyniadau gorau:

  • Be specific about visual elements, style, and mood
  • Include details about lighting, camera angles, and composition
  • Avoid contradictory or impossible requests

2. Trin Prosesu Anghydamserol

Mae'r broses gynhyrchu yn anghydamserol. Gweithredwch brosesau 'polling' neu webhooks priodol:

// 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. Adfer o Wallau

Gweithredwch resymeg ailgeisio gydag egwyl esbonyddol (exponential backoff):

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. Monitro Defnydd Credydau

Traciwch eich defnydd o gredydau er mwyn osgoi toriadau yn y gwasanaeth:

  • Check credit balance before large batch operations
  • Set up alerts for low credit thresholds
  • Implement credit-aware request queuing

Yn barod i ddechrau?

Ymunwch â miloedd o ddatblygwyr sy'n defnyddio Flux Pro API i greu cynnwys anhygoel

Cael Allwedd API Nawr Gweld y Prisiau