---
title: Kling نص إلى صورة | RunAPI
description: أنشئ صورًا قياسية وسلاسل مرتبة وصورًا طويلة للتجارة الإلكترونية أو صفحات
  الويب.
url: https://runapi.ai/ar/docs/api/kling/text-to-image.md
canonical: https://runapi.ai/ar/docs/api/kling/text-to-image
locale: ar
---

> نسخة HTML: https://runapi.ai/ar/docs/api/kling/text-to-image
> فهرس الموقع للوكلاء: https://runapi.ai/llms.txt

# Kling نص إلى صورة

## نظرة عامة

استخدم نقطة نهاية تحويل النص إلى صورة مع نموذج مدعوم. استخدم معرّف المهمة المُعاد لاسترداد حالتها، أو أدخل callback_url للتسليمات الموثقة أدناه.

### البدء السريع

1. أنشئ مفتاح API واضبطه كـ RUNAPI_API_KEY.
2. اختر نموذجاً مدعوماً وأرسل طلب POST يطابق مخطط ذلك النموذج.
3. احفظ معرّف المهمة المُعاد، ثم استطلع الحالة حتى تبلغ حالة نهائية أو تعالج عمليات الاستدعاء الموثقة أدناه.

## نقطة النهاية

POST /api/v1/kling/text_to_image

عنوان URL الأساسي: https://runapi.ai

إصدار API: v1

المصادقة: Authorization: Bearer YOUR_API_TOKEN

## النماذج المدعومة

افتح صفحة النموذج للاطلاع على التسعير الحالي وحدود المعدل وتفاصيل الاستخدام التجاري.

- [kling-v4-image](https://runapi.ai/ar/models/kling/v4-image)
- [kling-v4-long-image](https://runapi.ai/ar/models/kling/v4-long-image)

## مخطط الطلب

تعتمد الحقول والقيم المسموح بها على النموذج المحدد. عند التوفير، يستقبل callback_url عمليات تسليم المهمة الموثّقة أدناه.

### kling-v4-image

```json
{
  "aspect_ratio": {
    "default": "auto",
    "description": "نسبة أبعاد المخرجات.",
    "enum": [
      "auto",
      "9:16",
      "2:3",
      "3:4",
      "1:1",
      "4:3",
      "3:2",
      "16:9",
      "21:9"
    ],
    "type": "string"
  },
  "callback_url": {
    "description": "رابط Webhook لإشعارات غير متزامنة.",
    "type": "string"
  },
  "elements": {
    "description": "مراجع مسمّاة، يُحتسب كل منها مادة إدخال واحدة. يجب أن تكون الأسماء فريدة دون تمييز بين الأحرف الكبيرة والصغيرة؛ والاسمان image_N وobject_N محجوزان.",
    "items": {
      "properties": {
        "description": {
          "length": true,
          "max": 100,
          "type": "string"
        },
        "image_urls": {
          "items": {
            "type": "string"
          },
          "max_items": 4,
          "min_items": 2,
          "required": true,
          "type": "array"
        },
        "name": {
          "length": true,
          "max": 20,
          "min": 1,
          "required": true,
          "type": "string"
        },
        "tag": {
          "enum": [
            "character",
            "animal",
            "prop",
            "costume",
            "scene",
            "effect",
            "others"
          ],
          "type": "string"
        }
      },
      "type": "object"
    },
    "max_items": 10,
    "type": "array"
  },
  "mode": {
    "default": "default",
    "description": "توليد فردي/افتراضي أو سلسلة صور مترابطة.",
    "enum": [
      "default",
      "series"
    ],
    "type": "string"
  },
  "model": {
    "description": "معرّف نموذج الصور Kling 4.0.",
    "required": true,
    "type": "string"
  },
  "output_count": {
    "default": 1,
    "description": "من 1 إلى 9 في الوضع الافتراضي؛ ومن 2 إلى 10 إلزاميًا في وضع السلسلة.",
    "max": 10,
    "min": 1,
    "type": "integer"
  },
  "output_resolution": {
    "default": "2k",
    "description": "دقة الإخراج.",
    "enum": [
      "2k",
      "4k",
      "8k"
    ],
    "type": "string"
  },
  "prompt": {
    "description": "وصف الصورة؛ أشر إلى الصور المقدَّمة باستخدام @image_N أو إلى العناصر باستخدام @name.",
    "length": true,
    "max": 20000,
    "min": 1,
    "required": true,
    "type": "string"
  },
  "source_image_urls": {
    "description": "صور JPG أو PNG عامة عبر HTTP/HTTPS، بحجم أقصاه 20 ميغابايت لكل صورة. لا يتجاوز مجموع الصور والعناصر 10.",
    "items": {
      "type": "string"
    },
    "max_items": 10,
    "type": "array"
  }
}
```

### kling-v4-long-image

```json
{
  "callback_url": {
    "description": "رابط Webhook لإشعارات غير متزامنة.",
    "type": "string"
  },
  "length": {
    "default": "medium",
    "description": "طول صورة التجارة الإلكترونية.",
    "enum": [
      "short",
      "medium",
      "long"
    ],
    "type": "string"
  },
  "model": {
    "description": "معرّف نموذج الصور الطويلة Kling 4.0.",
    "required": true,
    "type": "string"
  },
  "output_resolution": {
    "default": "2k",
    "description": "دقة الإخراج.",
    "enum": [
      "1k",
      "2k"
    ],
    "type": "string"
  },
  "prompt": {
    "description": "وصف الصورة الطويلة. يجب أن تسمّي المراجع صورًا مقدَّمة: @image_N أو @style أو @subject.",
    "length": true,
    "max": 20000,
    "min": 1,
    "required": true,
    "type": "string"
  },
  "skill": {
    "description": "مهارة الصورة الطويلة؛ لا تميّز بين الأحرف الكبيرة والصغيرة.",
    "enum": [
      "ecommerce",
      "webpage"
    ],
    "required": true,
    "type": "string"
  },
  "source_image_urls": {
    "description": "صور منتجات التجارة الإلكترونية: ملفات JPG أو PNG عامة عبر HTTP/HTTPS، بحجم أقصاه 20 ميغابايت لكل ملف.",
    "items": {
      "type": "string"
    },
    "max_items": 3,
    "min_items": 1,
    "type": "array"
  },
  "style_image_url": {
    "description": "مرجع نمط اختياري لصفحة الويب: ملف JPG أو PNG عام عبر HTTP/HTTPS، بحجم أقصاه 20 ميغابايت.",
    "type": "string"
  },
  "subject_image_url": {
    "description": "مرجع موضوع اختياري لصفحة الويب: ملف JPG أو PNG عام عبر HTTP/HTTPS، بحجم أقصاه 20 ميغابايت.",
    "type": "string"
  }
}
```

#### القواعد الشرطية

تسري هذه المتطلبات عندما تتطابق جميع الشروط المدرجة.

- **عندما**: `model` = `kling-v4-image`; **غير مقبول**: `skill`, `length`, `style_image_url`, `subject_image_url`
- **عندما**: `mode` = `series`, `model` = `kling-v4-image`; **مطلوب**: `output_count`
- **عندما**: `mode` = `default`, `model` = `kling-v4-image`
- **عندما**: `mode absent`, `model` = `kling-v4-image`
- **عندما**: `model` = `kling-v4-long-image`; **غير مقبول**: `mode`, `output_count`, `elements`, `aspect_ratio`
- **عندما**: `model` = `kling-v4-long-image`, `skill` = `ecommerce`; **مطلوب**: `source_image_urls`; **غير مقبول**: `style_image_url`, `subject_image_url`
- **عندما**: `model` = `kling-v4-long-image`, `skill` = `webpage`; **غير مقبول**: `source_image_urls`, `length`

## إنشاء قبول

HTTP 202 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    },
    "task_replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "status"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## الاستطلاع قيد المعالجة

HTTP 200 - GET /api/v1/kling/text_to_image/:id

### مخطط الاستجابة

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "processing"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "id": "tsk_reference_demo",
  "status": "processing"
}
```

## اكتمل الاستطلاع

HTTP 200 - GET /api/v1/kling/text_to_image/:id

### مخطط الاستجابة

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "images": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "usage": {
      "properties": {
        "cost": {
          "type": "number"
        }
      },
      "required": [
        "cost"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  },
  "required": [
    "id",
    "status",
    "images",
    "usage"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "id": "tsk_reference_demo",
  "images": [
    {
      "url": "https://cdn.runapi.ai/public/samples/image.jpg"
    }
  ],
  "status": "completed",
  "usage": {
    "cost": 0.05
  }
}
```

## فشل الاستطلاع

HTTP 200 - GET /api/v1/kling/text_to_image/:id

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Task processing failed.",
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## استدعاء العميل: مكتمل

HTTP 200 - POST callback_url

### مخطط الاستجابة

```json
{
  "properties": {
    "id": {
      "type": "string"
    },
    "images": {
      "items": {
        "properties": {
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    },
    "usage": {
      "properties": {
        "cost": {
          "type": "number"
        }
      },
      "required": [
        "cost"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  },
  "required": [
    "id",
    "status",
    "images",
    "usage"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "id": "tsk_reference_demo",
  "images": [
    {
      "url": "https://cdn.runapi.ai/public/samples/image.jpg"
    }
  ],
  "status": "completed",
  "usage": {
    "cost": 0.05
  }
}
```

## استدعاء العميل: فشل

HTTP 200 - POST callback_url

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "properties": {
            "code": {
              "type": "string"
            },
            "limit_cents": {
              "type": "integer"
            },
            "message": {
              "type": "string"
            },
            "reset_at": {
              "format": "date-time",
              "type": [
                "string",
                "null"
              ]
            },
            "used_cents": {
              "type": "integer"
            },
            "window": {
              "enum": [
                "1h",
                "1d",
                "7d",
                "daily",
                "weekly",
                "monthly",
                "lifetime"
              ],
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object",
          "unevaluatedProperties": false
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": {
    "code": "generation_failed",
    "message": "Task processing failed."
  },
  "id": "tsk_reference_demo",
  "status": "failed"
}
```

## الأخطاء

HTTP 401 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Authentication required"
}
```

## الأخطاء

HTTP 401 - GET /api/v1/kling/text_to_image/:id

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Authentication required"
}
```

## الأخطاء

HTTP 400 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "رسالة خطأ قابلة للقراءة البشرية.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "ملخص التحقق القابل للقراءة البشرية.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "رسائل التحقق مفتاحها حقل الطلب العام، مع مصفوفة من السلاسل القابلة للقراءة البشرية لكل حقل.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### مثال على الاستجابة

```json
{
  "error": "model must be one of: kling-v4-image, kling-v4-long-image"
}
```

## الأخطاء

HTTP 402 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Insufficient balance"
}
```

## الأخطاء

HTTP 429 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "API key credit limit exceeded"
}
```

## الأخطاء

HTTP 409 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "The request uses features that are not supported for the selected model"
}
```

## الأخطاء

HTTP 429 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Rate limit reached. Please retry later."
}
```

## الأخطاء

HTTP 503 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Service under maintenance, please try again later"
}
```

## الأخطاء

HTTP 503 - POST /api/v1/kling/text_to_image

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "The request timed out"
}
```

## الأخطاء

HTTP 404 - GET /api/v1/kling/text_to_image/:id

### مخطط الاستجابة

```json
{
  "properties": {
    "error": {
      "description": "رسالة خطأ قابلة للقراءة البشرية.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### مثال على الاستجابة

```json
{
  "error": "Task with id 'tsk_reference_demo' not found"
}
```

## نماذج الأكواد المولَّدة

استخدم cURL مباشرةً، أو ثبّت SDK للغة البرمجة التي تستخدمها. كل نموذج يُرسل الطلب الذي تم التحقق من صحته كما هو موضح في هذا المرجع.

### curl

```curl
curl -X POST https://runapi.ai/api/v1/kling/text_to_image \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model":"kling-v4-image","prompt":"A red apple on a white table","output_resolution":"2k","output_count":1}'
```

### javascript

#### التثبيت

```bash
npm install @runapi.ai/kling
```

```javascript
import { KlingClient } from "@runapi.ai/kling";

const client = new KlingClient({ apiKey: process.env.RUNAPI_API_KEY });
const task = await client.textToImage.create({
  "model": "kling-v4-image",
  "prompt": "A red apple on a white table",
  "output_resolution": "2k",
  "output_count": 1
});
```

### python

#### التثبيت

```bash
pip install runapi-kling
```

```python
import os
from runapi.kling import KlingClient

client = KlingClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_image.create(
  model="kling-v4-image",
  prompt="A red apple on a white table",
  output_resolution="2k",
  output_count=1
)
```

### go

#### التثبيت

```bash
go get github.com/runapi-ai/kling-sdk/go@latest
```

```go
package main

import (
  "context"
  "log"
  "os"

  "github.com/runapi-ai/core-sdk/go/option"
  kling "github.com/runapi-ai/kling-sdk/go/kling"
)

func main() {
  client, err := kling.NewClient(option.WithAPIKey(os.Getenv("RUNAPI_API_KEY")))
  if err != nil {
    log.Fatal(err)
  }

  task, err := client.TextToImage.Create(context.Background(), kling.TextToImageParams{
    Model: kling.TextToImageModel("kling-v4-image"),
    Prompt: "A red apple on a white table",
    OutputResolution: "2k",
    OutputCount: 1,
  })
  if err != nil {
    log.Fatal(err)
  }
  _ = task
}
```

### ruby

#### التثبيت

```bash
gem install runapi-kling
```

```ruby
require "runapi/kling"

client = RunApi::Kling::Client.new(api_key: ENV.fetch("RUNAPI_API_KEY"))
task = client.text_to_image.create(
  model: "kling-v4-image",
  prompt: "A red apple on a white table",
  output_resolution: "2k",
  output_count: 1
)
```

### java

#### التثبيت

```kotlin
implementation("ai.runapi:runapi-kling")
```

```java
import ai.runapi.kling.KlingClient;
import ai.runapi.kling.types.TextToImageParams;
import ai.runapi.core.polling.TaskCreateResponse;

public final class Example {
  public static void main(String[] args) {
    KlingClient client = KlingClient.builder()
        .apiKey(System.getenv("RUNAPI_API_KEY"))
        .build();
    TaskCreateResponse task = client.textToImage().create(
        TextToImageParams.builder()
        .model(new ai.runapi.kling.types.TextToImageModel("kling-v4-image"))
        .prompt("A red apple on a white table")
        .outputResolution("2k")
        .outputCount(1)
            .build()
    );
  }
}
```

### php

#### التثبيت

```bash
composer require runapi-ai/kling
```

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use RunApi\Core\ClientOptions;
use RunApi\Kling\KlingClient;

$client = new KlingClient(new ClientOptions(apiKey: getenv('RUNAPI_API_KEY')));
$task = $client->textToImage->create([
  "model" => "kling-v4-image",
  "prompt" => "A red apple on a white table",
  "output_resolution" => "2k",
  "output_count" => 1
]);
```

## الأدلة ذات الصلة

- [المصادقة](https://runapi.ai/ar/docs/guides/authentication.md)
- [البدء السريع](https://runapi.ai/ar/docs/guides/task-api/quickstart.md)
- [صور Kling 4.0](https://runapi.ai/ar/docs/guides/task-api/kling-images.md)

---

## المزيد من RunAPI

- [الرئيسية](https://runapi.ai/ar/.md)
- [كتالوج النماذج](https://runapi.ai/ar/models.md)
- [الأسعار](https://runapi.ai/ar/pricing.md)
- [مزودو الخدمة](https://runapi.ai/ar/models)
- [معرض المطالبات](https://runapi.ai/ar/prompts.md)
- [التوثيق](https://runapi.ai/ar/docs/guides)
- [حزم SDK](https://runapi.ai/ar/sdk.md)
- [CLI](https://runapi.ai/ar/cli.md)
- [خادم MCP](https://runapi.ai/ar/mcp.md)
- [x402](https://runapi.ai/ar/x402.md)
- [Claude Code مقابل Cursor](https://runapi.ai/ar/claude-code-vs-cursor.md)
- [إعداد Cursor API](https://runapi.ai/ar/cursor-api-setup.md)
- [RunAPI مقابل OpenRouter](https://runapi.ai/ar/openrouter-alternative.md)
- [المؤسسات](https://runapi.ai/ar/contact.md)
- [برنامج الإحالة](https://runapi.ai/ar/referral-program.md)
- [اتصل بنا](https://runapi.ai/ar/contact.md)
- [الشروط](https://runapi.ai/ar/terms.md)
- [الخصوصية](https://runapi.ai/ar/privacy.md)
- [فهرس الموقع للوكلاء](https://runapi.ai/llms.txt)

التواصل: contact@runapi.ai

## البيانات المنظمة

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "ar",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/ar",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/ar/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "ar",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/ar",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/icon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "ar",
    "@type": "TechArticle",
    "headline": "Kling نص إلى صورة",
    "description": "أنشئ صورًا قياسية وسلاسل مرتبة وصورًا طويلة للتجارة الإلكترونية أو صفحات الويب.",
    "url": "https://runapi.ai/ar/docs/api/kling/text-to-image",
    "mainEntityOfPage": "https://runapi.ai/ar/docs/api/kling/text-to-image"
  }
]
```
