典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIImageBanana

Text-to-Image/Image-to-Image

POST/api/v1/image/generation

Header Parameters

Authorization*string

Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

_action*string

Fixed value i

model*string

Model name, supported: NB NBP NB2

Value in"NB" | "NBP" | "NB2"
messages*array<object>

Message list, only one message is supported.

[]?object
role?string

Message role, fixed value: user

content?array<object>

Content List

[]?object
type*string

Content type: text or image_url

text?string

Text content (required when type=text)

image_item?object

Image information (required when type=image_url)

image_url*string

Image URL

n?integer

NB/NBP/NB2 only support 1

size?string

Image aspect ratio, supported: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 1:8, 4:1, 8:1 (1:4, 1:8, 4:1, 8:1 supported only by NB2)

quality?string

Image resolution: NB supports 1K, NBP supports 1K/2K/4K, and NB2 supports 512/1K/2K/4K.

response_modalities?array<string>

Response modality, if provided, must include "IMAGE".

[]?string
tools?array<object>

Tool definition, supported by NBP/NB2, not supported by NB

[]?object
type*string

Tool type, fixed value: function

function*object

Function Definition

name*string

Function name, such as GWebSearch (Web Search)

extra_body?object

Model Extension Configuration

g_model?object

Google/Gemini Model Configuration

thinking_config?object

Thinking mode configuration, supported only by NB2

thinking_level?string

Thinking level, supported only by NB2, accepting only MINIMAL and HIGH.

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

code*integer

Status Code

data*object

Data Object

urls*array<string>

Result Set

[]?string
usage*object

Usage Information

images*integer

Number of Images

seconds*integer

Video Duration in Seconds

input_tokens*integer

Input Token Count

total_tokens*integer

Total Tokens

output_tokens*integer

Output token count

expired*string

Validity Period

task_id*string

Task ID

task_status*string

Task Status

message*string

Status Information

request_id*string

Request ID

curl -X POST "https://api.ygw.ai/api/v1/image/generation" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "_action": "string",    "model": "NB",    "messages": [      {}    ]  }'
{
  "code": 0,
  "data": {
    "urls": [
      "string"
    ],
    "usage": {
      "images": 0,
      "seconds": 0,
      "input_tokens": 0,
      "total_tokens": 0,
      "output_tokens": 0
    },
    "expired": "string",
    "task_id": "string",
    "task_status": "string"
  },
  "message": "string",
  "request_id": "string"
}