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

# クイックスタート

このガイドでは、[black-forest-labs/flux-kontext-pro/text-to-image](https://sunra.ai/models/black-forest-labs/flux-kontext-pro/text-to-image) など、人気のモデルエンドポイントの使用方法について説明します。
始める前に、[ダッシュボード](https://sunra.ai/dashboard/api-tokens)から API キーを取得していることを確認してください。
これは、sunra API へのリクエストを認証するために必要です。

開始するには、以下のプログラミング言語を選択してください。

## JavaScript/Node.js

まず、クライアントパッケージをインストールし、API キーで設定します。

<CodeGroup>
  ```bash npm theme={null}
  npm install @sunra/client
  ```

  ```bash pnpm theme={null}
  pnpm add @sunra/client
  ```

  ```bash yarn theme={null}
  yarn add @sunra/client
  ```
</CodeGroup>

API キーを環境変数として設定します。

```bash theme={null}
export SUNRA_KEY="your-api-key-here"
```

設定が完了したら、sunra [クライアント](/client-libraries/javascript)を使用してモデル API エンドポイントを呼び出すことができます。

```javascript theme={null}
import { sunra } from "@sunra/client";

// オプションで、環境変数で設定したものとは異なる API キーでクライアントを設定します
sunra.config({
  credentials: "YOUR_SUNRA_KEY",
});

const result = await sunra.subscribe("black-forest-labs/flux-kontext-pro/text-to-image", {
  input: {
    prompt: "水彩画風のキノコの下で本を読んでいるメガネをかけたウサギ。",
    width: 1024,
    height: 768,
    output_format: "jpeg"
  },
});
```

## Python

pip を使用して Python クライアントライブラリをインストールします。

```bash theme={null}
pip install sunra-client
```

API キーを環境変数として設定します。

```bash theme={null}
export SUNRA_KEY="your-api-key-here"
```

クライアントを設定して使用します。

```python theme={null}
import sunra_client

result = sunra_client.subscribe(
    "black-forest-labs/flux-kontext-pro/text-to-image",
    arguments={
        "prompt": "水彩画風のキノコの下で本を読んでいるメガネをかけたウサギ。",
        "width": 1024,
        "height": 768,
        "output_format": "jpeg"
    },
    with_logs=True,
    on_enqueue=print,
    on_queue_update=print,
)
print(result)
```

## Java

好みのビルドシステムを使用して、Java クライアントライブラリをプロジェクトに追加します。

<CodeGroup>
  ```kotlin Gradle theme={null}
  implementation("ai.sunra.client:sunra-client:0.1.5")
  ```

  ```xml Maven theme={null}
  <dependency>
      <groupId>ai.sunra.client</groupId>
      <artifactId>sunra-client</artifactId>
      <version>0.1.5</version>
  </dependency>
  ```
</CodeGroup>

API キーを環境変数として設定します。

```bash theme={null}
export SUNRA_KEY="your-api-key-here"
```

クライアントを設定して使用します。

```java theme={null}
import ai.sunra.client.*;
import ai.sunra.client.queue.*;
import java.util.Map;
import com.google.gson.JsonObject;
import java.util.function.Consumer;

ClientConfig config = ClientConfig.builder()
    .withCredentials(CredentialsResolver.fromEnv())
    .build();

SunraClient client = SunraClient.withConfig(config);
Map<String, Object> input = Map.of(
    "prompt", "水彩画風のキノコの下で本を読んでいるメガネをかけたウサギ。",
    "width", 1024,
    "height", 768,
    "output_format", "jpeg"
);

Consumer<QueueStatus.StatusUpdate> statusUpdateHandler = update -> {
    String status = update.getStatus().toString();
    String message = String.format("\nステータス更新: %s, リクエストID: %s",
        status, update.getRequestId());
    System.out.println(message);
};

SubscribeOptions<JsonObject> options = SubscribeOptions.<JsonObject>builder()
    .input(input)
    .resultType(JsonObject.class)
    .onQueueUpdate(statusUpdateHandler)
    .logs(true)
    .build();

Output<JsonObject> response = client.subscribe("black-forest-labs/flux-kontext-pro/text-to-image", options);
System.out.println("完了しました！");
System.out.println(response.getData());
```

## 次のステップ

Flux kontext pro や Kling v2 master など、さまざまなモデルをすぐに使える API として提供しています。これらは[モデルプレイグラウンド](https://sunra.ai/models)で確認できます。

モデルを使用するには、その「API」タブにアクセスして URL、ソースコード、使用例を確認し、アプリケーションにシームレスに統合できるようにします。

各クライアントライブラリの詳細については、[クライアントライブラリのドキュメント](/client-libraries)をご覧ください。
