# Quickstart

> Run any neural network in three lines with the FlyMy.AI Python SDK. API key setup, sync and async examples, errors, and what to do next.

## Python

### Installing Python SDK

```sh
pip install flymyai
```

### Getting an API Key

1. Register on [FlyMy.AI](https://flymy.ai)
2. Go to your [profile](https://app.flymy.ai/profile) and get your key, username, and project_name

### Example: Generate an Image
```python
# Install the FlyMyAI package
# pip install flymyai
from flymyai import client, FlyMyAIPredictException
import urllib.request

# Set secret api key. You can find your api key in the profile settings
apikey = "fly-***"
# Set the model name
model = "flymyai/nano-banana-2_1"
# Prepare the input data
payload = {
  "prompt": "An astronaut riding a rainbow unicorn, cinematic, dramatic, photorealistic",
}

# Initialize the client
fma_client = client(apikey=apikey)
try:
    response = fma_client.predict(
        model=model,
        payload=payload
    )
    # Nano Banana 2.1 returns image URLs under "images"
    image_url = response.output_data["images"][0]
    urllib.request.urlretrieve(image_url, "sample_output.jpg")
    print("Saved sample_output.jpg")
except FlyMyAIPredictException as e:
    print(e)
    raise e
```

## JavaScript

### Installing JavaScript SDK

```bash
npm install flymyai-js-client
```

or

```bash
yarn add flymyai-js-client
```

### Example: Generate an Image

```js
import { FlyMyAI } from "flymyai-js-client";
import { writeFile } from "node:fs/promises";

// Initialize the client
const client = new FlyMyAI({ apiKey: "fly-***" });

// Set the model name
const model = "flymyai/nano-banana-2_1";

// Prepare the input data
const payload = {
  prompt: "An astronaut riding a rainbow unicorn, cinematic, dramatic, photorealistic",
};

try {
  const response = await client.predict(payload, model);

  // Nano Banana 2.1 returns image URLs under "images"
  const imageUrl = response.output_data["images"][0];
  const image = await fetch(imageUrl);
  await writeFile("sample_output.jpg", Buffer.from(await image.arrayBuffer()));

  console.log("Saved sample_output.jpg");
} catch (error) {
  console.error("Error making prediction:", error);
  throw error;
}
```

## More
- [Guides](https://docs.flymy.ai/guides/generate-images.md)
- [API](https://docs.flymy.ai/api/overview.md)
