Using Generative APIs
Access
- A valid API key is needed.
Authentication
All requests to the Scaleway Generative APIs must include an Authorization
HTTP header with your API key prefixed by Bearer
.
We recommend exporting your secret key as an environment variable, which you can then pass directly in your curl request as follows. Remember to replace the example value with your own API secret key.
export SCW_SECRET_KEY=720438f9-fcb9-4ebb-80a7-808ebf15314b
Run the following curl request once you have exported your environment variable:
curl -X GET \-H "Authorization: Bearer ${SCW_SECRET_KEY}" \"https://api.scaleway.ai/v1/models"
When using the OpenAI Python SDK, the API key is set once during client initialization, and the SDK automatically manages the inclusion of the Authorization header in all API requests. In contrast, when directly integrating with the Scaleway Generative APIs, you are responsible for manually setting the Authorization header with the API key for each request to ensure proper authentication.
Content types
Scaleway Generative APIs accept JSON in request bodies and returns JSON in response bodies.
You will want to send the Content-Type: application/json
HTTP header in your POST requests.
curl --request POST \--url https://api.scaleway.ai/v1/chat/completions \--header "Authorization: Bearer ${SCW_SECRET_KEY}" \--header "Content-Type: application/json" \--data '{}'
Permissions
Permissions define the actions a user or an application can perform on Scaleway Generative APIs. They are managed using Scaleway’s Identity and Access Management interface.
Owner status or certain IAM permissions allow you to perform actions in the intended Organization.
Querying AI models hosted by Scaleway Generative APIs will require any of the following permission sets:
- GenerativeApisModelAccess
- GenerativeApisFullAccess
- AllProductsFullAccess
Projects
You can scope your Generative APIs consumption to a Project. This is helpful to restrict IAM users’ access to only the Project they are working on, or to isolate your bills between Projects.
- Find your Project ID in your Project settings
- Insert your Project ID in the Generative APIs service URL, for example:
https://api.scaleway.ai/78e655b5-feb0-417c-bb3f-8c448bd0e8da/v1
The Project ID is hidden for the default Project.