Skip to content

Commit 5a264aa

Browse files
committed
fix(genapi): fix wording
1 parent 8f2c1af commit 5a264aa

File tree

1 file changed

+28
-146
lines changed

1 file changed

+28
-146
lines changed

pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx

Lines changed: 28 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ meta:
55
content:
66
h1: Integrating Scaleway Generative APIs with popular AI tools
77
paragraph: Scaleway's Generative APIs provide a powerful way to integrate AI capabilities into your applications. By leveraging our APIs, you can tap into the latest advancements in natural language processing, computer vision, and more. In this guide, we'll show you how to integrate Scaleway's Generative APIs with popular AI tools like LangChain, LlamaIndex, and OpenAI.
8-
tags: generative-apis, ai, language-models
8+
tags: generative-apis ai language-models
99
dates:
1010
validation: 2025-02-18
1111
posted: 2025-02-18
@@ -19,129 +19,58 @@ The following table compares AI tools and libraries supported by Scaleway's Gene
1919

2020
| Tool/Library | Description | Use cases | Integration effort |
2121
| --- | --- | --- | --- |
22-
| [OpenAI](#openai-compatible-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low |
22+
| [OpenAI client](#openai-client-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low |
2323
| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications | Inference, embeddings, document indexing and retrieval | Medium |
24-
| [LlamaIndex](#llamaindex-document-indexing-and-retrieval) | Library for indexing and retrieving documents using AI models | Document indexing and retrieval, question answering | Medium |
2524
| [Continue Dev](#continue-dev-ai-coding-assistance) | Library for AI-powered coding assistance | Code completion, code review | Low |
2625
| [Chatbox AI](#chatbox-ai) | Desktop client for generative APIs, available on Windows, Mac, Linux | AI copilot for documents, images, or code| Low |
27-
| [Transformers (Hugging Face)](#transformers-hugging-face-integration) | Library for pre-trained models for natural language processing | Text generation, language translation, text summarization | Medium |
28-
| [cURL/Python](#api-clients-and-custom-integrations) | Direct API clients for custom integrations | Custom applications, data processing | High |
26+
| [cURL/Python](#custom-http-integrations) | Direct HTTP API calls for custom integrations | Custom applications, data processing | High |
2927

3028
<Message type="note">
3129
The integration effort is subjective and may vary depending on the specific use case and requirements.
3230
</Message>
3331

34-
## OpenAI-compatible libraries
32+
## OpenAI client libraries
3533

3634
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.
3735

3836
### Configuration
3937

40-
To use the OpenAI library with Scaleway's Generative APIs, you'll need to set the API key and base URL in your OpenAI-compatible client:
38+
To use the OpenAI client library with Scaleway's Generative APIs, first install the required dependencies:
39+
```bash
40+
pip install openai
41+
```
42+
43+
Then set the API key and base URL in your OpenAI-compatible client:
4144
```python
42-
import openai
43-
openai.api_key = "<API secret key>"
44-
openai.api_base = "https://api.scaleway.ai/v1"
45-
response = openai.ChatCompletion.create(
46-
model="llama-3.1-8b-instruct",
47-
messages=[{"role": "user", "content": "Tell me a joke about AI"}]
45+
from openai import OpenAI
46+
client = OpenAI(
47+
base_url="https://api.scaleway.ai/v1",
48+
api_key="<API secret key>"
4849
)
49-
print(response["choices"][0]["message"]["content"])
5050
```
5151
<Message type="tip">
5252
Make sure to replace `<API secret key>` with your actual API key.
5353
</Message>
5454

55-
### Using OpenAI for text generation
55+
### Using OpenAI client for text generation
5656

57-
To use OpenAI for text generation, you can create a `ChatCompletion` object and call the `create` method:
57+
To use OpenAI client for text generation, you can create a `client.chat.completions` object and call the `create` method:
5858
```python
59-
response = openai.ChatCompletion.create(
59+
response = client.chat.completions.create(
6060
model="llama-3.1-8b-instruct",
6161
messages=[{"role": "user", "content": "Tell me a joke about AI"}]
6262
)
63-
print(response["choices"][0]["message"]["content"])
63+
print(response.choices[0].message.content)
6464
```
6565

6666
## LangChain (RAG & LLM applications)
6767

6868
LangChain is a popular library for building AI applications. Scaleway's Generative APIs support LangChain for both inference and embeddings.
6969

70-
### Configuration
71-
72-
To use LangChain with Scaleway's Generative APIs, you'll need to install the required dependencies:
73-
```bash
74-
pip install langchain langchain_openai langchain_postgres psycopg2
75-
```
76-
Next, set up the API connection:
77-
```python
78-
from langchain_openai import OpenAIEmbeddings, ChatOpenAI
79-
import os
80-
os.environ["OPENAI_API_KEY"] = "<API secret key>"
81-
os.environ["OPENAI_API_BASE"] = "https://api.scaleway.ai/v1"
82-
llm = ChatOpenAI(model="llama-3.1-8b-instruct")
83-
embeddings = OpenAIEmbeddings(model="bge-multilingual-gemma2")
84-
```
85-
<Message type="tip">
86-
Make sure to replace `<API secret key>` with your actual API key.
87-
</Message>
88-
89-
### Using LangChain for inference
90-
91-
To use LangChain for inference, you can create a `ChatOpenAI` object and call the `ask` method:
92-
```python
93-
response = llm.ask("What is the capital of France?")
94-
print(response)
95-
```
96-
### Using LangChain for embeddings
97-
98-
To use LangChain for embeddings, you can create an `OpenAIEmbeddings` object and call the `compute_embeddings` method:
99-
```python
100-
embeddings = OpenAIEmbeddings(model="bge-multilingual-gemma2")
101-
text = "This is an example sentence."
102-
embedding = embeddings.compute_embeddings(text)
103-
print(embedding)
104-
```
105-
## LlamaIndex (document indexing & retrieval)
106-
107-
LlamaIndex is a library for indexing and retrieving documents using AI models. Scaleway's Generative APIs support LlamaIndex for document indexing and retrieval.
108-
109-
### Configuration
110-
111-
To use LlamaIndex with Scaleway's Generative APIs, you'll need to install the required dependencies:
112-
```bash
113-
pip install llama-index
114-
```
115-
Next, set up the embedding model:
116-
```python
117-
from llama_index.embeddings.openai import OpenAIEmbedding
118-
embed_model = OpenAIEmbedding(
119-
api_key="<API secret key>",
120-
api_base="https://api.scaleway.ai/v1",
121-
model="bge-multilingual-gemma2"
122-
)
123-
```
12470
<Message type="tip">
125-
Make sure to replace `<API secret key>` with your actual API key.
71+
Refer to our dedicated documentation for [implementing Retrieval-Augmented Generation (RAG) with LangChain and Scaleway Generative APIs](/tutorials/how-to-implement-rag-generativeapis/)
12672
</Message>
12773

128-
### Indexing documents
129-
130-
To index documents using LlamaIndex, you'll need to create a `VectorStoreIndex` object and call the `add_documents` method:
131-
```python
132-
from llama_index import VectorStoreIndex, SimpleDirectoryReader
133-
documents = SimpleDirectoryReader("data").load_data()
134-
index = VectorStoreIndex.from_documents(documents, embed_model=embed_model)
135-
```
136-
### Retrieving documents
137-
138-
To retrieve documents using LlamaIndex, you can call the `query` method on the `VectorStoreIndex` object:
139-
```python
140-
query_engine = index.as_query_engine()
141-
response = query_engine.query("Summarize this document")
142-
print(response)
143-
```
144-
14574
## Continue Dev (AI coding assistance)
14675

14776
Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more.
@@ -152,30 +81,6 @@ Continue Dev is a library that provides AI-powered coding assistance. Scaleway's
15281
- [Integrating Continue Dev with IntelliJ IDEA](/generative-apis/reference-content/adding-ai-to-intellij-using-continue/)
15382
</Message>
15483

155-
### Configuration
156-
157-
To use Continue Dev with Scaleway's Generative APIs, you'll need to modify the `continue.json` file to add Scaleway's API:
158-
```json
159-
{
160-
"models": [
161-
{
162-
"title": "Qwen2.5-Coder-32B-Instruct",
163-
"provider": "scaleway",
164-
"model": "qwen2.5-coder-32b-instruct",
165-
"apiKey": "<API secret key>"
166-
}
167-
],
168-
"embeddingsProvider": {
169-
"provider": "scaleway",
170-
"model": "bge-multilingual-gemma2",
171-
"apiKey": "<API secret key>"
172-
}
173-
}
174-
```
175-
<Message type="tip">
176-
Make sure to replace `<API secret key>` with your actual API key.
177-
</Message>
178-
17984
## Chatbox AI
18085

18186
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.
@@ -184,35 +89,7 @@ Chatbox AI is a powerful AI client and smart assistant, compatible with Scaleway
18489
Refer to our dedicated documentation for [installing and configuring Chatbox AI with Generative APIs](/tutorials/configure-chatboxai-with-generative-apis/)
18590
</Message>
18691

187-
188-
## Transformers (Hugging Face integration)
189-
190-
Hugging Face's `transformers` library provides a range of pre-trained models for natural language processing. Scaleway's Generative APIs support Hugging Face integration for text generation and more.
191-
192-
### Configuration
193-
194-
To use Hugging Face with Scaleway's Generative APIs, you'll need to install the `transformers` library and set up your API key:
195-
```python
196-
from transformers import pipeline
197-
generator = pipeline(
198-
"text-generation",
199-
model="llama-3.1-8b-instruct",
200-
tokenizer="meta-llama/Llama-3-8b",
201-
api_base="https://api.scaleway.ai/v1",
202-
api_key="<API secret key>"
203-
)
204-
```
205-
<Message type="tip">
206-
Make sure to replace `<API secret key>` with your actual API key.
207-
</Message>
208-
209-
### Using Hugging Face for text generation
210-
211-
To use Hugging Face for text generation, you can call the `generator` function:
212-
```python
213-
print(generator("Write a short poem about the ocean"))
214-
```
215-
## API clients and custom integrations
92+
## Custom HTTP integrations
21693

21794
You can interact with Scaleway's Generative APIs directly using any HTTP client.
21895

@@ -232,9 +109,14 @@ curl https://api.scaleway.ai/v1/chat/completions \
232109
Make sure to replace `<API secret key>` with your actual API key.
233110
</Message>
234111

235-
### Python example
112+
### Python HTTP example
236113

237-
To use Python with Scaleway's Generative APIs, you can use the following code:
114+
To perform HTTP requests with Scaleway's Generative APIs, install the `requests` dependency:
115+
```bash
116+
pip install requests
117+
```
118+
119+
Then, you can use the following code:
238120
```python
239121
import requests
240122
headers = {
@@ -250,4 +132,4 @@ print(response.json()["choices"][0]["message"]["content"])
250132
```
251133
<Message type="tip">
252134
Make sure to replace `<API secret key>` with your actual API key.
253-
</Message>
135+
</Message>

0 commit comments

Comments
 (0)