|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: Integrating Scaleway Generative APIs with popular AI tools |
| 4 | + description: Learn how to integrate Scaleway's Generative APIs with popular AI tools to unlock the full potential of your applications. |
| 5 | +content: |
| 6 | + h1: Integrating Scaleway Generative APIs with popular AI tools |
| 7 | + 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 |
| 9 | +dates: |
| 10 | + validation: 2025-02-18 |
| 11 | + posted: 2025-02-18 |
| 12 | +--- |
| 13 | + |
| 14 | +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. |
| 15 | + |
| 16 | +## Comparison of AI tools and libraries |
| 17 | + |
| 18 | +The following table compares AI tools and libraries supported by Scaleway's Generative APIs: |
| 19 | + |
| 20 | +| Tool/Library | Description | Use cases | Integration effort | |
| 21 | +| --- | --- | --- | --- | |
| 22 | +| [OpenAI client](#openai-client-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low | |
| 23 | +| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications | Inference, embeddings, document indexing and retrieval | Medium | |
| 24 | +| [Continue Dev](#continue-dev-ai-coding-assistance) | Library for AI-powered coding assistance | Code completion, code review | Low | |
| 25 | +| [cURL/Python](#custom-http-integrations) | Direct HTTP API calls for custom integrations | Custom applications, data processing | High | |
| 26 | + |
| 27 | +<Message type="note"> |
| 28 | + The integration effort is subjective and may vary depending on the specific use case and requirements. |
| 29 | +</Message> |
| 30 | + |
| 31 | +## OpenAI client libraries |
| 32 | + |
| 33 | +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. |
| 34 | + |
| 35 | +### Configuration |
| 36 | + |
| 37 | +To use the OpenAI client library with Scaleway's Generative APIs, first install the required dependencies: |
| 38 | +```bash |
| 39 | +pip install openai |
| 40 | +``` |
| 41 | + |
| 42 | +Then set the API key and base URL in your OpenAI-compatible client: |
| 43 | +```python |
| 44 | +from openai import OpenAI |
| 45 | +client = OpenAI( |
| 46 | + base_url="https://api.scaleway.ai/v1", |
| 47 | + api_key="<API secret key>" |
| 48 | +) |
| 49 | +``` |
| 50 | +<Message type="tip"> |
| 51 | + Make sure to replace `<API secret key>` with your actual API key. |
| 52 | +</Message> |
| 53 | + |
| 54 | +### Using OpenAI client for text generation |
| 55 | + |
| 56 | +To use OpenAI client for text generation, you can create a `client.chat.completions` object and call the `create` method: |
| 57 | +```python |
| 58 | +response = client.chat.completions.create( |
| 59 | + model="llama-3.1-8b-instruct", |
| 60 | + messages=[{"role": "user", "content": "Tell me a joke about AI"}] |
| 61 | +) |
| 62 | +print(response.choices[0].message.content) |
| 63 | +``` |
| 64 | + |
| 65 | +## LangChain (RAG & LLM applications) |
| 66 | + |
| 67 | +LangChain is a popular library for building AI applications. Scaleway's Generative APIs support LangChain for both inference and embeddings. |
| 68 | + |
| 69 | +<Message type="tip"> |
| 70 | + Refer to our dedicated documentation for |
| 71 | + - [Implementing Retrieval-Augmented Generation (RAG) with LangChain and Scaleway Generative APIs](/tutorials/how-to-implement-rag-generativeapis/) |
| 72 | +</Message> |
| 73 | + |
| 74 | +## Continue Dev (AI coding assistance) |
| 75 | + |
| 76 | +Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more. |
| 77 | + |
| 78 | +<Message type="tip"> |
| 79 | + Refer to our dedicated documentation for |
| 80 | + - [Integrating Continue Dev with Visual Studio Code](/generative-apis/reference-content/adding-ai-to-vscode-using-continue/) |
| 81 | + - [Integrating Continue Dev with IntelliJ IDEA](/generative-apis/reference-content/adding-ai-to-intellij-using-continue/) |
| 82 | +</Message> |
| 83 | + |
| 84 | +## Custom HTTP integrations |
| 85 | + |
| 86 | +You can interact with Scaleway's Generative APIs directly using any HTTP client. |
| 87 | + |
| 88 | +### cURL example |
| 89 | + |
| 90 | +To use cURL with Scaleway's Generative APIs, you can use the following command: |
| 91 | +```bash |
| 92 | +curl https://api.scaleway.ai/v1/chat/completions \ |
| 93 | + -H "Authorization: Bearer <API secret key>" \ |
| 94 | + -H "Content-Type: application/json" \ |
| 95 | + -d '{ |
| 96 | + "model": "llama-3.1-8b-instruct", |
| 97 | + "messages": [{"role": "user", "content": "What is quantum computing?"}] |
| 98 | + }' |
| 99 | +``` |
| 100 | +<Message type="tip"> |
| 101 | + Make sure to replace `<API secret key>` with your actual API key. |
| 102 | +</Message> |
| 103 | + |
| 104 | +### Python HTTP example |
| 105 | + |
| 106 | +To perform HTTP requests with Scaleway's Generative APIs, install the `requests` dependency: |
| 107 | +```bash |
| 108 | +pip install requests |
| 109 | +``` |
| 110 | + |
| 111 | +Then, you can use the following code: |
| 112 | +```python |
| 113 | +import requests |
| 114 | +headers = { |
| 115 | + "Authorization": "Bearer <API secret key>", |
| 116 | + "Content-Type": "application/json" |
| 117 | +} |
| 118 | +data = { |
| 119 | + "model": "llama-3.1-8b-instruct", |
| 120 | + "messages": [{"role": "user", "content": "Explain black holes"}] |
| 121 | +} |
| 122 | +response = requests.post("https://api.scaleway.ai/v1/chat/completions", json=data, headers=headers) |
| 123 | +print(response.json()["choices"][0]["message"]["content"]) |
| 124 | +``` |
| 125 | +<Message type="tip"> |
| 126 | + Make sure to replace `<API secret key>` with your actual API key. |
| 127 | +</Message> |
0 commit comments