API 参考
Midjourney Shorten-Prompt
提交同步Shorten Prompt请求,并在同一响应中接收结果。
01
概览
提交Shorten Prompt请求,并直接使用同一响应返回的结果。
快速开始
- 创建 API Key,并将其设置为 RUNAPI_API_KEY。
- 发送与请求 Schema 匹配的 POST 请求。
- 从成功响应正文中读取结果。
端点
- 基础 URL
https://runapi.ai- API 版本
v1- 身份验证
Authorization: Bearer YOUR_API_TOKEN
02
支持的模型
打开模型页可查看当前价格、限流和商业使用详情。
03
JSON 请求体请求 Schema
只发送此端点声明的字段。
请求体1 个字段
promptstring
必填
04
HTTP 200成功响应
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"prompts": {
"items": {
"type": "string"
},
"maxItems": 5,
"minItems": 1,
"type": "array"
}
},
"required": [
"prompts",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"prompts": [
"Cinematic mountain landscape at sunrise.",
"Mountain vista in warm morning light."
]
}
05
HTTP 401错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Authentication required"
}
06
HTTP 400错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"oneOf": [
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "Human-readable validation summary.",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
响应示例
JSON
{
"error": "prompt is required"
}
07
HTTP 402错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Insufficient balance"
}
08
HTTP 429错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "API key credit limit exceeded"
}
09
HTTP 409错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "The request uses features that are not supported for the selected model"
}
10
HTTP 429错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Rate limit reached. Please retry later."
}
11
HTTP 503错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Service under maintenance, please try again later"
}
12
HTTP 504错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "The request timed out"
}
13
HTTP 400错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Bad Request"
}
14
HTTP 429错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Too Many Requests"
}
15
HTTP 500错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Internal Server Error"
}
16
HTTP 502错误
POST /api/v1/midjourney/shorten_prompt
响应 Schema
JSON
{
"properties": {
"error": {
"description": "Human-readable error message.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
响应示例
JSON
{
"error": "Bad Gateway"
}
17
生成的代码示例
直接使用 cURL,或安装所用语言的 SDK。每个示例都会提交本参考中经过验证的请求。
安装
Shell
pip install runapi-midjourney
PYTHON
import os
from runapi.midjourney import MidjourneyClient
client = MidjourneyClient(api_key=os.environ["RUNAPI_API_KEY"])
result = client.shorten_prompt.run(
prompt="A detailed cinematic mountain landscape at sunrise."
)