This service is free while in beta. Specific terms and conditions apply.
Generative APIs - Quickstart
Generative APIs offer seamless access to pre-configured, serverless endpoints of leading AI models. No need to configure hardware or deploy your own models.
Hosted in European data centers and priced competitively per million tokens used, these APIs enable efficient and scalable integration of AI capabilities into your applications.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A valid API key
- Python 3.7+ installed on your system
Start with the Generative APIs Playground
Scaleway’s Playground is in development, stay tuned!
Install the OpenAI Python SDK
To start using Generative APIs in your code, you can install the OpenAI Python SDK. Run the following command:
pip install openai
Ensure Python is installed on your local machine. If you need to install Python, download it from python.org.
Configure and set your API key and service URL
- Have your API key ready or generate a new one from the Scaleway console.
- Use the following code in your Python script:
from openai import OpenAIclient = OpenAI(base_url="https://api.scaleway.ai/v1",api_key="<SCW_API_KEY>")
Make sure that you replace <SCW_API_KEY>
with the API key obtained from your Scaleway account.
It is recommended to store your API keys securely using environment variables or secret management tools to prevent unauthorized access.
Send your first API request
You are now ready to make your first API request. Below is an example of generating a description of a futuristic city:
from openai import OpenAI# Initialize the client with your base URL and API keyclient = OpenAI(base_url="https://api.scaleway.ai/v1",api_key="<SCW_API_KEY>")# Create a chat completion for Llama 3.1 8b instructcompletion = 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 the resultprint(completion.choices[0].message["content"])
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 for more advanced features and usage.