The integration effort is subjective and may vary depending on the specific use case and requirements.
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 librariesLink to this anchor
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 |
cURL/Python | Direct HTTP API calls for custom integrations | Custom applications, data processing | High |
OpenAI client librariesLink to this anchor
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.
ConfigurationLink to this anchor
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 OpenAIclient = OpenAI(base_url="https://api.scaleway.ai/v1",api_key="<API secret key>")
Make sure to replace <API secret key>
with your actual API key.
Using OpenAI client for text generationLink to this anchor
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)Link to this anchor
LangChain is a popular library for building AI applications. Scaleway’s Generative APIs support LangChain for both inference and embeddings.
PythonLink to this anchor
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 HumanMessagefrom langchain.chat_models import init_chat_modelfrom langchain_core.tools import tool@tooldef add(a: int, b: int) -> int:"""Adds a and b."""return a + b@tooldef multiply(a: int, b: int) -> int:"""Multiplies a and b."""return a * btools = [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.pyThe result of 3 * 12 is 36.
Refer to our dedicated documentation for
implementing Retrieval-Augmented Generation (RAG) with LangChain and Scaleway Generative APIsLlamaIndex (advanced RAG applications)Link to this anchor
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-likeCreate 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 OpenAILikefrom llama_index.core.llms import ChatMessagellm = 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,)TipMake sure to replace
<API secret key>
with your actual API key.You can then 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.pyThe 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)Link to this anchor
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/openaiEdit 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);TipMake sure to replace
<API secret key>
with your actual API secret key.Run
main.js
:node main.jsThe 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)Link to this anchor
Continue Dev is a library that provides AI-powered coding assistance. Scaleway’s Generative APIs support Continue Dev for code completion and more.
Refer to our dedicated documentation for
Zed AI (coding assistance)Link to this anchor
Zed is an IDE (Integrated Development Environment) including AI coding assistance support. Scaleway’s Generative APIs support Zed AI code completion and more.
Refer to our dedicated documentation for
connecting Zed to Generative APIsChatbox AILink to this anchor
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.
Refer to our dedicated documentation for
installing and configuring Chatbox AI with Generative APIsBolt.diy (code generation)Link to this anchor
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 theBolt.diy 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.
Only models that have a maximum output token of at least 8000 tokens are supported. Refer to the
list of Generative APIs models for more information.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/v1OPENAI_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.
If you first configured your credentials through the browser, you also need to reset your browser’s cookies for your localhost domain (as Bolt.diy stores model provider configuration information in the browser).
If you want to limit access to a specific Scaleway Project, replace API endpoint with https://api.scaleway.ai/###PROJECT_ID###/v1/
since the default URL https://api.scaleway.ai/v1/
can only be used with the default project.
Chatbox AILink to this anchor
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.
Refer to our dedicated documentation for
installing and configuring Chatbox AI with Generative APIsCustom HTTP integrationsLink to this anchor
You can interact with Scaleway’s Generative APIs directly using any HTTP client.
cURL exampleLink to this anchor
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?"}]}'
Make sure to replace <API secret key>
with your actual API key.
Python HTTP exampleLink to this anchor
To perform HTTP requests with Scaleway’s Generative APIs, install the requests
dependency:
pip install requests
Then, you can use the following code:
import requestsheaders = {"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"])
Make sure to replace <API secret key>
with your actual API key.