> ## 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.

# Quickstart

In this guide, we'll walk you through using one of our popular model endpoints, such as [black-forest-labs/flux-kontext-pro/text-to-image](https://sunra.ai/models/black-forest-labs/flux-kontext-pro/text-to-image).
Before diving in, you'll need an API key — see [Authentication](/platform/authentication) for how to create one and configure your environment.

Choose your preferred programming language below to get started:

## JavaScript/Node.js

To get started, install the client package and configure it with your API key:

<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>

Set your API key as an environment variable:

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

Once configured, you can invoke our Model API endpoint using the sunra [client](/client-libraries/javascript):

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

// Optionally, configure the client with a different API key other than the one set in the environment variable
sunra.config({
  credentials: "YOUR_SUNRA_KEY",
});

const result = await sunra.subscribe("black-forest-labs/flux-kontext-pro/text-to-image", {
  input: {
    prompt: "A rabbit wearing glasses reading a book under a mushroom in watercolor style.",
    width: 1024,
    height: 768,
    output_format: "jpeg"
  },
});
```

## Python

Install the Python client library using pip:

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

Set your API key as an environment variable:

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

Configure and use the client:

```python theme={null}
import sunra_client

result = sunra_client.subscribe(
    "black-forest-labs/flux-kontext-pro/text-to-image",
    arguments={
        "prompt": "A rabbit wearing glasses reading a book under a mushroom in watercolor style.",
        "width": 1024,
        "height": 768,
        "output_format": "jpeg"
    },
    with_logs=True,
    on_enqueue=print,
    on_queue_update=print,
)
print(result)
```

## Java

Add the Java client library to your project using your preferred build system:

<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>

Set your API key as an environment variable:

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

Configure and use the client:

```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", "A rabbit wearing glasses reading a book under a mushroom in watercolor style.",
    "width", 1024,
    "height", 768,
    "output_format", "jpeg"
);

Consumer<QueueStatus.StatusUpdate> statusUpdateHandler = update -> {
    String status = update.getStatus().toString();
    String message = String.format("\nStatus Update: %s, Request 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("Completed!");
System.out.println(response.getData());
```

## Next Steps

We offer various models like Flux kontext pro and Kling v2 master as ready-to-use APIs. Explore these on our [Model Playground](https://sunra.ai/models).

To use a model, visit its "API" tab to find the URL, source code, and usage examples, helping you integrate it seamlessly into your applications.

For more detailed information about each client library, visit our [client libraries documentation](/client-libraries).
