---
title: Generative APIs - Quickstart
description: Get started with Scaleway Generative APIs for powerful AI-driven content generation. Follow this guide to set up, configure, and make your first API request.
tags: generative-apis ai-data quickstart
dates:
  validation: 2026-04-16
  posted: 2024-09-04
---
import Requirements from '@macros/iam/requirements.mdx'


Scaleway Generative APIs provide programmatic access to AI models for generating new content, such as text and code. 

By using our pre-configured, serverless endpoints of leading AI models, you eliminate the need to configure hardware or deploy your own models.

Hosted in European data centers and priced competitively per million tokens used, Generative APIs enable efficient and scalable integration of AI capabilities into your applications.

<Requirements />

  - A Scaleway account logged into the [console](https://console.scaleway.com)
  - [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
  - A valid [API key](/iam/how-to/create-api-keys/)
  - Python 3.7+ installed on your system

## Interacting with Generative APIs via the playground

The Scaleway console provides a web playground for chat-based models hosted on Generative APIs. This allows you to interact with these models via a visual interface, sending your prompt and getting an immediate text-based response.

### How to access the playground

1. Navigate to **Generative APIs** under the **AI** section of the [Scaleway console](https://console.scaleway.com/) side menu. The list of available models displays. Select the **Serverless** toggle button.

2. Click the name of the chat model you want to try. Alternatively, click <Icon name="more" /> next to the chat model, and click **Try model** in the menu. 

The web playground displays.

### How to use the playground

1. Choose a model from the drop-down list at the top of the page.

2. Enter a prompt at the bottom of the page, for example `Tell me a joke`.

    <Message type="tip">
    You can also click one of the suggested prompts in the conversation area, such as `Translate text`, `Rewrite email` or `Code a pong game`, to instantly send a pre-prepared prompt and get the model's response.
    </Message>

3. Edit the hyperparameters listed on the right column, for example the default temperature for more or less randomness on the model's output.

4. Click the send button to send your prompt and view the model's response in the conversation area, for example `Why don’t scientists trust atoms anymore? Because they make up everything!` 

    <Message type="tip">
    You can click **View code** next to the model dropdown to get code snippets you can integrate directly into your Python, Javascript, and cURL code bases when [querying a model programmatically](#interacting-with-generative-apis-programmatically). These snippets are configured according to the settings you have entered in the playground.
    </Message>

## Interacting with Generative APIs programmatically

This example shows you how to start using Generative APIs in your Python code, via the OpenAI Python SDK.

### How to install the OpenAI Python SDK

<Message type="tip">
  Ensure Python is installed on your local machine. If you need to install Python, download it from [python.org](https://www.python.org/downloads/).
</Message>

Run the following command:

```bash
pip install openai
```

### How to configure and set your API key and service URL

1. Have your [Scaleway API key](/iam/how-to/create-api-keys/) ready, or generate a new one from the Scaleway console.

2. Add the following code to your Python script:

    ```py
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.scaleway.ai/v1", # # Scaleway's Generative APIs - Serverless service URL
        api_key="<SCW_SECRET_KEY>" # Your unique API secret key from Scaleway
    )
    ```

    Make sure that you replace `<SCW_SECRET_KEY>` with the API key obtained from your Scaleway account.

    <Message type="tip">
      We recommend storing your API keys securely using environment variables or [secret management tools](/secret-manager/) to prevent unauthorized access.
    </Message>

### How to send your first API request

After installing OpenAI and adding setting up the client with the base URL and API key, you are now ready to make your first API request. 

Below is an example for generating a description of a futuristic city.

1. Ensure your code already contains the openai import statement and creation of a configured OpenAI client as [shown above](#how-to-configure-and-set-your-api-key-and-service-url).

2. Create a chat completion for Llama 3.1 8b instruct by adding the following to your code:

    ```python
    completion = client.chat.completions.create(
      model="llama-3.1-8b-instruct",
      messages=[{"role": "user", "content": "Describe a futuristic city with advanced technology and green energy solutions."}],
      temperature=0.7,
      max_tokens=100
    )
    ```

3. Output the result by adding the following to your code:

    ```python
    print(completion.choices[0].message.content)
    ```

    <Message type="tip">
    The whole code snippet should look like this:

    ```python
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.scaleway.ai/v1", # # Scaleway's Generative APIs - Serverless service URL
        api_key="<SCW_SECRET_KEY>" # Your unique API secret key from Scaleway
    )

    # Create chat completion
    completion = client.chat.completions.create(
      model="llama-3.1-8b-instruct",
      messages=[{"role": "user", "content": "Describe a futuristic city with advanced technology and green energy solutions."}],
      temperature=0.7,
      max_tokens=100

    # Output model's response
    print(completion.choices[0].message.content)
    )
    ```
    </Message>
    
This very simple example demonstrates how the Chat API can be used to generate creative content based on your prompts.

## Going further

Now that you are familiar with the basics, explore the full potential of Generative APIs by customizing your API requests. Refer to our [How-to guides](/generative-apis/how-to/) for more advanced features and usage.
