Integrating Scaleway Generative APIs with popular AI tools
Scaleway's Generative APIs are designed to provide easy access to the latest AI models and techniques. Our APIs are built on top of a robust infrastructure that ensures scalability, reliability, and security. With our APIs, you can integrate AI capabilities into your applications, such as text generation, image classification, and more.
Comparison of AI tools and libraries
The following table compares AI tools and libraries supported by Scaleway's Generative APIs:
Tool/Library | Description | Use cases | Integration effort |
---|---|---|---|
OpenAI client | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low |
LangChain | Library for building AI applications leveraging RAG | Inference, embeddings, document indexing and retrieval | Medium |
LlamaIndex | Library for building advanced AI RAG applications | Knowledge graph building, document retrieval, data indexing | Medium |
Continue Dev | IDE extension for AI-powered coding assistance | Code completion, code review | Low |
Zed AI | IDE including AI-powered coding assistance | Code completion, code review | Low |
Bolt.diy | Software to create applications | Code generation, code edition | Low |
Chatbox AI | Desktop client for generative APIs, available on Windows, Mac, Linux | AI copilot for documents, images, or code | Low |
n8n | Workflow automation tool | Connecting AI agents, apps, and services. | Low |
cURL/Python | Direct HTTP API calls for custom integrations | Custom applications, data processing | High |
OpenAI client libraries
Scaleway Generative APIs follow OpenAI's API structure, making integration straightforward. To get started, you'll need to install the OpenAI library and set up your API key.
Configuration
To use the OpenAI client library with Scaleway's Generative APIs, first install the required dependencies:
pip install openai
Then set the API key and base URL in your OpenAI-compatible client:
from openai import OpenAI
client = OpenAI(
base_url="https://api.scaleway.ai/v1",
api_key="<API secret key>"
)
Using OpenAI client for text generation
To use OpenAI client for text generation, you can create a client.chat.completions
object and call the create
method:
response = client.chat.completions.create(
model="llama-3.1-8b-instruct",
messages=[{"role": "user", "content": "Tell me a joke about AI"}]
)
print(response.choices[0].message.content)
LangChain (RAG & LLM applications)
LangChain is a popular library for building AI applications. Scaleway's Generative APIs support LangChain for both inference and embeddings.
Python
Function calling
- Run the following commands to install LangChain and its dependencies:
$ pip install 'langchain>=0.3.24' $ pip install 'langchain-core>=0.3.55' $ pip install 'langchain-openai>=0.3.14' $ pip install 'langchain-text-splitters>=0.3.8'
- Create a file named
tools.py
and paste the code below into it to import and create the tools examples:from langchain_core.messages import HumanMessage from langchain.chat_models import init_chat_model from langchain_core.tools import tool @tool def add(a: int, b: int) -> int: """Adds a and b.""" return a + b @tool def multiply(a: int, b: int) -> int: """Multiplies a and b.""" return a * b tools = [add, multiply]
- Configure the
init_chat_model
function to use Scaleway's Generative APIs.llm = init_chat_model("mistral-small-3.1-24b-instruct-2503", model_provider="openai", base_url="https://api.scaleway.ai/v1")
- Use the
llm
object and thetools
list to generate a response to your query with the following code:query = "What is 3 * 12?" # You can also try the following query: # query = "What is 42 + 4?" messages = [HumanMessage(query)] # We initialize the messages list with the user's query. ai_msg = llm_with_tools.invoke(messages) # We generate a response to the query. messages.append(ai_msg) # We append the response to the messages list. for tool_call in ai_msg.tool_calls: selected_tool = {"add": add, "multiply": multiply}[tool_call["name"].lower()] # Depending on the tool name, we select the appropriate tool. tool_msg = selected_tool.invoke(tool_call) # We invoke the selected tool with the tool call. messages.append(tool_msg) # We append the tool's response to the messages list. print(llm_with_tools.invoke(messages).content) # We print the content of the final response.
- Run
tools.py
:$ python tools.py The result of 3 * 12 is 36.
LlamaIndex (advanced RAG applications)
LlamaIndex is an open-source framework for building Large Language Models (LLMs) based applications, especially optimizing RAG (Retrieval Augmented Generation) pipelines.
-
Install the required dependencies to use the LlamaIndex framework with Scaleway's Generative APIs:
pip install llama-index-llms-openai-like
-
Create a file
main.py
and add the following code to it to configure theOpenAILike
client and your secret key:from llama_index.llms.openai_like import OpenAILike from llama_index.core.llms import ChatMessage llm = OpenAILike( model="llama-3.1-8b-instruct", api_key="<API secret key>", api_base="https://api.scaleway.ai/v1", max_tokens=512, temperature=0.7, top_p=1, presence_penalty=0, )
-
Interact with the LLM by sending messages to the model with the following code:
response = llm.chat([ChatMessage("Could you tell me about Scaleway please ?")]) print(response)
-
Finally, run
main.py
:python main.py
The LLM response should display an answer:
Generally, Scaleway is a reliable and secure cloud provider that offers a range of services for businesses and developers.
Javascript (Typescript)
To perform chat conversations with Langchain, first install langchain
and @langchain/openai
packages using your node package manager.
-
Use the following command to install Langchain using
npm
(yarn
andpnpm
are also available):npm install langchain @langchain/openai
-
Edit your
package.json
file to ensure it has the"type": "module"
property:{ "type": "module", "dependencies": { "@langchain/openai": "^0.4.4", "langchain": "^0.3.19" } }
-
Create a
main.js
file and add the following content to it:import { ChatOpenAI } from "@langchain/openai"; const chat = new ChatOpenAI({ apiKey: "<API secret key>", model: "llama-3.1-8b-instruct", configuration: { baseURL: "https://api.scaleway.ai/v1", } }); const response = await chat.invoke("Tell me a joke"); console.log(response.content);
-
Run
main.js
:node main.js
The model answer should display:
Why couldn't the bicycle stand up by itself? Because it was two-tired.
Note that other Langchain objects from OpenAI client library are also compatible, such as OpenAI
and OpenAIEmbeddings
.
Continue Dev (AI coding assistance)
Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more.
Zed AI (coding assistance)
Zed is an IDE (Integrated Development Environment) including AI coding assistance support. Scaleway's Generative APIs support Zed AI code completion and more.
Bolt.diy (code generation)
Bolt.diy is a software enabling users to create web applications from the prompt.
- Install and launch Bolt.diy locally. Follow the setup instructions provided in the Bolt.diy GitHub repository.
- Once Bolt.diy is running, open the interface in your web browser.
- Click the icon next to the Bolt logo to display the sidebar.
- Click the cogwheel icon in the sidebar's bottom left corner to open the Settings.
- Click Local Providers to add a new external provider configuration.
- Toggle the switch next to OpenAILike to enable it. Then, enter the Scaleway API endpoint:
https://api.scaleway.ai/v1
as the base URL. - In Bolt's main menu, select
OpenAILike
and input your Scaleway Secret Key as theOpenAILike API Key
. - Select one of the supported models from Scaleway Generative APIs. For best results with Bolt.diy, which requires a significant amount of output tokens (8000 by default), start with the
gemma-3-27b-it
model. - Enter your prompt in the Bolt.diy interface to see your application being generated.
Alternatively, you can also setup your Scaleway Secret Key by renaming .env.example
to .env
, adding corresponding environment variables values and restarting Bolt.diy:
OPENAI_LIKE_API_BASE_URL=https://api.scaleway.ai/v1
OPENAI_LIKE_API_KEY=###SCW_SECRET_KEY###
To enable configuration from .env
is taken into account, you still need to enable OpenAILike from Bolt interface in Settings > Local Providers section.
Chatbox AI
Chatbox AI is a powerful AI client and smart assistant, compatible with Scaleway's Generative APIs service. It is available across multiple platforms, including Windows, macOS, Android, iOS, Web, and Linux.
n8n
n8n is an open-source workflow automation tool that allows users to build automated workflows by connecting various AI agents, apps, and services. It provides a visual interface to facilitate the creation of workflows.
Custom HTTP integrations
You can interact with Scaleway's Generative APIs directly using any HTTP client.
cURL example
To use cURL with Scaleway's Generative APIs, you can use the following command:
curl https://api.scaleway.ai/v1/chat/completions \
-H "Authorization: Bearer <API secret key>" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.1-8b-instruct",
"messages": [{"role": "user", "content": "What is quantum computing?"}]
}'
Python HTTP example
To perform HTTP requests with Scaleway's Generative APIs, install the requests
dependency:
pip install requests
Then, you can use the following code:
import requests
headers = {
"Authorization": "Bearer <API secret key>",
"Content-Type": "application/json"
}
data = {
"model": "llama-3.1-8b-instruct",
"messages": [{"role": "user", "content": "Explain black holes"}]
}
response = requests.post("https://api.scaleway.ai/v1/chat/completions", json=data, headers=headers)
print(response.json()["choices"][0]["message"]["content"])