> ## Documentation Index
> Fetch the complete documentation index at: https://www.krea.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Krea 2

> Krea 2 API 参考文档，涵盖模型、参数、定价以及生成滑块，助您掌控我们首个专为创作控制打造的基础图像模型。

export const ModelOverviewCard = ({name, description, icon, href}) => {
  const resolvedIcon = (() => {
    if (typeof icon !== "string" || !icon.startsWith("/") || icon.startsWith("//")) return icon;
    if (typeof window === "undefined") return icon;
    const base = "/docs";
    const under = window.location.pathname === base || window.location.pathname.startsWith(base + "/");
    return under && !icon.startsWith(base + "/") ? base + icon : icon;
  })();
  return <a href={href} className="group relative block rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-black overflow-hidden hover:border-black dark:hover:border-white transition-all duration-200 p-6">
      {}
      <div className="flex items-center justify-center w-8 h-8 rounded-lg mb-4 transition-colors duration-200">
        {icon && <img src={resolvedIcon} alt={`${name} logo`} className="w-8 h-8 object-contain transition-all duration-200" />}
      </div>

      {}
      <div className="space-y-2">
        <h3 className="text-lg font-semibold text-black dark:text-white transition-colors">
          {name}
        </h3>
        <p className="text-sm text-gray-600 dark:text-gray-400 line-clamp-4">
          {description}
        </p>
      </div>

      {}
      <div className="absolute top-6 right-6 opacity-0 group-hover:opacity-100 transition-opacity duration-200">
        <svg className="w-4 h-4 text-black dark:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
        </svg>
      </div>
    </a>;
};

export const HeroHeader = ({image, video, title, description}) => {
  return <div className="relative aspect-[2/1] h-[30vh] w-full rounded-lg overflow-hidden mb-8">
      {}
      {video && <video autoPlay muted loop playsInline className="absolute top-0 left-0 w-full h-full object-cover hidden md:block m-0" style={{
    zIndex: 1,
    objectPosition: "20% 20%"
  }}>
          <source src={video} type="video/webm" />
        </video>}

      {}
      <img src={image} alt="" className={`absolute top-0 left-0 m-0 w-full h-full object-cover ${video ? "md:hidden" : "block"}`} style={{
    zIndex: 1,
    objectPosition: "20% 20%"
  }} />

      {}
      <div className="absolute inset-0 bg-gradient-to-t from-black/70 via-black/30 to-black/10 flex flex-col justify-end p-8 dark:hidden" style={{
    zIndex: 2
  }}>
        <h1 className="text-4xl font-bold text-white m-0 drop-shadow-[0_2px_4px_rgba(0,0,0,0.5)]">
          {title}
        </h1>
        <p className="text-lg text-white/95 mt-2 drop-shadow-[0_1px_2px_rgba(0,0,0,0.5)]">
          {description}
        </p>
      </div>

      {}
      <div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-black/20 hidden dark:flex flex-col justify-end p-8" style={{
    zIndex: 2
  }}>
        <h1 className="text-4xl font-bold text-white m-0 drop-shadow-[0_2px_4px_rgba(0,0,0,0.5)]">
          {title}
        </h1>
        <p className="text-lg text-white/95 mt-2 drop-shadow-[0_1px_2px_rgba(0,0,0,0.5)]">
          {description}
        </p>
      </div>
    </div>;
};

<HeroHeader image="https://s.krea.ai/docs/krea-2-hero.webp" title="Krea 2" description="我们的首个图像基础模型——从零构建，赋予你完整的创作掌控力。" />

Krea 2 是我们的首个图像基础模型，完全从零开始训练，让你对所生成的每一张图像的外观、质感与创作方向拥有完全的掌控。

**它的独特之处：**

* **美学多样性** — Krea 2 能生成种类繁多的风格，尤其擅长其他模型往往会"压平"的艺术与表现性方向。
* **风格迁移** — 市面上最先进的风格迁移系统。从一张或多张参考图像中提取风格，并精准地应用到你的输出上。
* **可调节的创造力** — `creativity` 是一个可调参数。在高值下，模型会为你给出的任何内容加入美学深度、解读与视觉丰富度。
* **情绪板** — 传入包含数十张图像的完整情绪板，Krea 2 将理解其整体创作方向，并生成与之契合的输出。

<a href="https://www.krea.ai/k2-feed" target="_blank" rel="noopener noreferrer" className="not-prose group flex items-center justify-between gap-4 my-8 rounded-xl !bg-black !text-white dark:!bg-white dark:!text-black hover:opacity-90 transition-opacity px-5 py-4">
  <div className="flex-1">
    <div className="text-base font-semibold">浏览画廊</div>
    <div className="text-sm opacity-80">数百个 Krea 2 输出及其提示词。</div>
  </div>

  <svg className="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M14 5l7 7m0 0l-7 7m7-7H3" />
  </svg>
</a>

## 选择一个变体

Krea 2 API 提供两个变体。两者支持相同的公开请求结构——差异主要体现在速度、模型规模、训练阶段以及输出的特征上。

<CardGroup cols={1}>
  <Card title="Krea 2 Medium" icon="bolt">
    更小、更快、更具成本效益。大量的后训练让输出在多次生成之间格外稳定和一致。

    **最擅长：** 插画、动漫、绘画以及其他富有表现力或艺术性的风格。
  </Card>

  <Card title="Krea 2 Large" icon="layer-group">
    规模超过 Medium 的 2 倍，后训练更轻。输出更原始、更具质感、更灵活——在最佳状态下，Large 能产出 Medium 无法匹敌的结果。

    **最擅长：** 写实摄影、原始质感（运动模糊、颗粒、低动态范围）、富有表现力的艺术风格。
  </Card>
</CardGroup>

<Tip>
  **不确定该从哪个开始？** 一般用途的稳定输出请使用 Medium；当你想要最丰富的质感或写实效果时，请使用 Large。
</Tip>

## 定价

| 变体         | 文生图     | 含风格参考   | 含情绪板    |
| ---------- | ------- | ------- | ------- |
| **Medium** | \$0.030 | \$0.035 | \$0.040 |
| **Large**  | \$0.060 | \$0.065 | \$0.070 |

<Note>
  将情绪板**与**风格参考组合使用不会增加单次生成的价格——你按情绪板费率付费（Medium \$0.040 / Large \$0.070）。
</Note>

## 端点

| 变体         | 端点                                        |
| ---------- | ----------------------------------------- |
| **Medium** | `POST /generate/image/krea/krea-2/medium` |
| **Large**  | `POST /generate/image/krea/krea-2/large`  |

## 快速开始

提交一次生成请求并轮询结果。所有请求都需要 Bearer token——如果你还没有，请参见 [API Keys 与计费](/developers/api-keys-and-billing)。

<CodeGroup>
  ```javascript Node.js theme={null}
  // npm install @krea-ai/sdk
  import { Krea } from "@krea-ai/sdk";

  const krea = new Krea({ apiKey: process.env.KREA_API_KEY });

  const result = await krea.subscribe("image/krea/krea-2/medium", {
    input: {
      prompt: "a cinematic glass cabin beside a frozen lake at sunrise",
      aspect_ratio: "16:9",
      resolution: "1K",
    },
  });

  // https://gen.krea.ai/images/80ead844-02a6-467d-ba9e-fcd401bcb9a6.png
  console.log(result.data?.urls[0]);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.krea.ai/generate/image/krea/krea-2/medium \
    -H "Authorization: Bearer $KREA_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "A cinematic product photo of a glass lamp on a marble table",
      "aspect_ratio": "4:5",
      "resolution": "1K",
      "creativity": "medium"
    }'

  # Then poll the returned job_id
  curl https://api.krea.ai/jobs/<job_id> \
    -H "Authorization: Bearer $KREA_API_TOKEN"
  ```

  ```python Python theme={null}
  import os
  import time
  import requests

  API_BASE = "https://api.krea.ai"
  API_TOKEN = os.environ["KREA_API_TOKEN"]

  def wait_for_job(job_id):
      while True:
          response = requests.get(
              f"{API_BASE}/jobs/{job_id}",
              headers={"Authorization": f"Bearer {API_TOKEN}"},
          )
          response.raise_for_status()
          job = response.json()
          if job["status"] == "completed":
              return job
          if job["status"] in ("failed", "cancelled"):
              raise RuntimeError(f"Job {job['status']}")
          time.sleep(3)

  response = requests.post(
      f"{API_BASE}/generate/image/krea/krea-2/medium",
      headers={
          "Authorization": f"Bearer {API_TOKEN}",
          "Content-Type": "application/json",
      },
      json={
          "prompt": "A cinematic product photo of a glass lamp on a marble table",
          "aspect_ratio": "4:5",
          "resolution": "1K",
          "creativity": "medium",
      },
  )
  response.raise_for_status()
  job = wait_for_job(response.json()["job_id"])
  print(job["result"]["urls"])
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"net/http"
  	"os"
  	"time"
  )

  const apiBase = "https://api.krea.ai"

  func waitForJob(client *http.Client, jobID, token string) (map[string]any, error) {
  	for {
  		req, _ := http.NewRequest("GET", fmt.Sprintf("%s/jobs/%s", apiBase, jobID), nil)
  		req.Header.Set("Authorization", "Bearer "+token)
  		resp, err := client.Do(req)
  		if err != nil {
  			return nil, err
  		}
  		var job map[string]any
  		json.NewDecoder(resp.Body).Decode(&job)
  		resp.Body.Close()
  		switch job["status"] {
  		case "completed":
  			return job, nil
  		case "failed", "cancelled":
  			return nil, fmt.Errorf("job %s", job["status"])
  		}
  		time.Sleep(3 * time.Second)
  	}
  }

  func main() {
  	token := os.Getenv("KREA_API_TOKEN")
  	client := &http.Client{}

  	payload, _ := json.Marshal(map[string]any{
  		"prompt":       "A cinematic product photo of a glass lamp on a marble table",
  		"aspect_ratio": "4:5",
  		"resolution":   "1K",
  		"creativity":   "medium",
  	})

  	req, _ := http.NewRequest("POST", apiBase+"/generate/image/krea/krea-2/medium", bytes.NewBuffer(payload))
  	req.Header.Set("Authorization", "Bearer "+token)
  	req.Header.Set("Content-Type", "application/json")

  	resp, _ := client.Do(req)
  	var created map[string]any
  	json.NewDecoder(resp.Body).Decode(&created)
  	resp.Body.Close()

  	job, err := waitForJob(client, created["job_id"].(string), token)
  	if err != nil {
  		panic(err)
  	}
  	fmt.Println(job["result"])
  }
  ```
</CodeGroup>

<Tip>
  Krea 2 Large 的生成可能耗时更长，因此对于生产工作负载，建议使用 [`X-Webhook-URL`](/developers/webhooks) 请求头而非轮询。
</Tip>

## 参数

`krea-2/medium` 与 `krea-2/large` 接受相同的公开请求体。

| 字段                       | 类型      | 说明                                                                        |
| ------------------------ | ------- | ------------------------------------------------------------------------- |
| `prompt`                 | string  | **必填。** 描述图像的文本提示词。                                                       |
| `aspect_ratio`           | string  | 取值之一：`1:1`、`4:3`、`3:2`、`16:9`、`2.35:1`、`4:5`、`2:3`、`9:16`。                |
| `resolution`             | string  | 目前仅支持 `1K`。                                                               |
| `seed`                   | number  | 可选。使用相同的 seed + prompt 可复现一次生成。                                           |
| `creativity`             | enum    | `raw`、`low`、`medium`（默认）、`high`。详见下文。                                     |
| `image_style_references` | array   | 可选。参见[风格迁移](/developers/krea-2/style-transfer)。                           |
| `moodboards`             | array   | 可选。参见[情绪板](/developers/krea-2/moodboards)。每次请求最多 1 个情绪板。                  |
| `styles`                 | array   | 可选的训练风格（LoRA）。                                                            |
| `intensity`              | integer | 可选。`-100` 到 `100`，默认 `0`。参见[生成滑杆](/developers/krea-2/generative-sliders)。 |
| `complexity`             | integer | 可选。`-100` 到 `100`，默认 `0`。参见[生成滑杆](/developers/krea-2/generative-sliders)。 |
| `movement`               | integer | 可选。`-100` 到 `100`，默认 `0`。参见[生成滑杆](/developers/krea-2/generative-sliders)。 |

<h3 id="creativity">
  Creativity
</h3>

`creativity` 控制模型在你所写内容之上扩展的程度。当提示词较短或较模糊时，模型会补齐缺失的部分——风格、构图、镜头角度、配色——而 `creativity` 决定它可以发挥的自由度。

<AccordionGroup>
  <Accordion title="raw — 不扩展">
    模型只渲染你明确描述过的内容。适合每个细节都已指定的、艺术指导严密的提示词。
  </Accordion>

  <Accordion title="low — 贴近提示词">
    扩展极少。模型紧贴字面提示词，仅填补明显的空缺。
  </Accordion>

  <Accordion title="medium — 平衡（默认）">
    默认行为。模型在不偏离提示词意图的前提下加入合理的解读。
  </Accordion>

  <Accordion title="high — 富有表现力的解读">
    强力扩展。模型会在风格、氛围与美学方面进行有意义的创意发挥——最适合简短或开放式的提示词，让模型给你带来惊喜。
  </Accordion>
</AccordionGroup>

## 功能深入

<CardGroup cols={2}>
  <Card title="风格迁移" icon="palette" href="/developers/krea-2/style-transfer">
    从一张或多张参考图像中提取风格，并以可调强度应用到你的输出上。
  </Card>

  <Card title="情绪板" icon="grid-2" href="/developers/krea-2/moodboards">
    引用 Krea 情绪板以设定整体视觉方向——配色、质感、氛围与构图。
  </Card>

  <Card title="生成滑杆" icon="sliders" href="/developers/krea-2/generative-sliders">
    无需重写提示词，即可调节每次生成的强度、复杂度与动感。
  </Card>
</CardGroup>

## 开源

如果你更愿意自托管或微调模型，而不是（或者除了）调用托管 API，Krea 2 也以开源形式发布。我们在 Hugging Face 上发布了两个 checkpoint：

* **Krea 2 RAW** — 未蒸馏的基础 checkpoint。多样且可塑性强，面向微调、后训练以及 LoRA 训练。
* **Krea 2 Turbo** — 一个 8 步蒸馏 checkpoint，面向快速文生图推理。在 RAW 上训练的 LoRA 设计为可以干净地应用到 Turbo 上。

| 资源                         | 链接                                                                   |
| -------------------------- | -------------------------------------------------------------------- |
| Hugging Face 上的 checkpoint | [huggingface.co/krea/Krea-2-Raw](https://krea.ai/krea-2/huggingface) |
| GitHub 上的模型代码              | [github.com/krea-ai/krea-2](https://krea.ai/krea-2/github)           |
| 技术报告                       | [Krea 2 技术报告](https://krea.ai/krea-2/technical-report)               |

### 许可

开源版本以两条许可证轨道发布：

* **[Community License](https://krea.ai/krea-2-licensing)** — 用于研究、个人与非商业项目的免费、非独占使用，以及营收低于阈值的商业用途。须遵守 [Acceptable Use Policy](https://krea.ai/krea-2-use-policy)。
* **[Commercial License](https://krea.ai/krea-2-commercial-license)** — 面向超过 Community License 营收阈值的商业用途的企业级条款。请联系 `opensource@krea.ai`。

<Note>
  本页所记录的托管 Krea 2 API 由标准 [API 条款](/developers/api-keys-and-billing) 管辖 — 调用 `krea-2/medium` 或 `krea-2/large` 不需要接受开源许可证。
</Note>

## API 参考

<div className="grid grid-cols-1 md:grid-cols-2 gap-4 hidden dark:grid">
  <ModelOverviewCard name="Krea 2 Medium" href="/api-reference/krea/krea-2-medium" icon="/images/logo/krea-logo-icon-dark.svg" description="更快、更便宜，在插画、动漫与表现性风格上表现稳定。" />

  <ModelOverviewCard name="Krea 2 Large" href="/api-reference/krea/krea-2-large" icon="/images/logo/krea-logo-icon-dark.svg" description="更强——写实摄影、原始质感与最具灵活性的输出。" />
</div>

<div className="grid grid-cols-1 md:grid-cols-2 gap-4 block dark:hidden">
  <ModelOverviewCard name="Krea 2 Medium" href="/api-reference/krea/krea-2-medium" icon="/images/logo/krea-logo-icon-light.svg" description="更快、更便宜，在插画、动漫与表现性风格上表现稳定。" />

  <ModelOverviewCard name="Krea 2 Large" href="/api-reference/krea/krea-2-large" icon="/images/logo/krea-logo-icon-light.svg" description="更强——写实摄影、原始质感与最具灵活性的输出。" />
</div>
