Skip to content

Prompt 增强

由于人类语言往往过于简洁,直接输入 AI 可能会导致结果缺乏细节。本功能利用大语言模型将简单的关键词扩展为包含光影、材质、构图等细节的专业提示词,显著提升生图质量。

典型应用场景

  • 生图助理:帮助用户优化输入,即使是新手也能生成大师级作品
  • 自动化流程:在批量生图任务中,对原始输入进行质量预处理

本页使用的 API 参考 POST /images/prompt_enhancements

基础示例

bash
curl -X POST 'https://api.v2fun.ai/api/v1/images/prompt_enhancements' \
  -H 'Authorization: Bearer $V2FUN_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
      "prompt": "A beautiful sunset over the mountains",
      "system_prompt": "You are a helpful assistant that generates detailed image descriptions from simple prompts."
    }'
javascript
const response = await fetch('https://api.v2fun.ai/api/v1/images/prompt_enhancements', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer $V2FUN_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "A beautiful sunset over the mountains",
    "system_prompt": "You are a helpful assistant that generates detailed image descriptions from simple prompts."
  }),
});
const data = await response.json();
python
import requests

resp = requests.post(
    'https://api.v2fun.ai/api/v1/images/prompt_enhancements',
    headers={
        'Authorization': 'Bearer $V2FUN_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        "prompt": "A beautiful sunset over the mountains",
        "system_prompt": "You are a helpful assistant that generates detailed image descriptions from simple prompts."
    },
)
print(resp.json())
java
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
String body = "{\"prompt\":\"A beautiful sunset over the mountains\",\"system_prompt\":\"You are a helpful assistant that generates detailed image descriptions from simple prompts.\"}";
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.v2fun.ai/api/v1/images/prompt_enhancements"))
    .header("Authorization", "Bearer $V2FUN_API_KEY")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = client.send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

核心用例

智能提示词扩写

输入简单概念(如“森林中的女孩”),获得包含具体环境描写、艺术风格定义和光影细节的增强提示词。

bash
curl -X POST 'https://api.v2fun.ai/api/v1/images/prompt_enhancements' \
  -H 'Authorization: Bearer $V2FUN_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
      "prompt": "a girl in forest",
      "system_prompt": "Expand the input into a vivid, detailed description suitable for high-quality image generation."
    }'
javascript
const response = await fetch('https://api.v2fun.ai/api/v1/images/prompt_enhancements', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer $V2FUN_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "a girl in forest",
    "system_prompt": "Expand the input into a vivid, detailed description suitable for high-quality image generation."
  }),
});
const data = await response.json();
python
import requests

resp = requests.post(
    'https://api.v2fun.ai/api/v1/images/prompt_enhancements',
    headers={
        'Authorization': 'Bearer $V2FUN_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        "prompt": "a girl in forest",
        "system_prompt": "Expand the input into a vivid, detailed description suitable for high-quality image generation."
    },
)
print(resp.json())
java
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
String body = "{\"prompt\":\"a girl in forest\",\"system_prompt\":\"Expand the input into a vivid, detailed description suitable for high-quality image generation.\"}";
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.v2fun.ai/api/v1/images/prompt_enhancements"))
    .header("Authorization", "Bearer $V2FUN_API_KEY")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();
HttpResponse<String> response = client.send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
原始 Prompt
a girl in forest
输出结果
A photorealistic portrait of a young woman standing gracefully in an ancient temperate forest during golden hour. She has shoulder-length wavy chestnut hair, fair skin, wearing a flowing linen dress. Sunlight pierces through the canopy in visible volumetric rays, casting dappled patterns. Shot with shallow depth of field, cinematic color grading, 8K resolution.