Skip to content

Commit c0e1b1e

Browse files
committed
docs: readme
1 parent 3059f8d commit c0e1b1e

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

README.md

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
# AI21 API Client
1+
<h1 align="center">
2+
<a href="https://github.com/AI21Labs/ai21-typescript">AI21 Labs TypeScript SDK</a>
3+
</h1>
4+
5+
<p align="center">
6+
<a href="https://github.com/AI21Labs/ai21-typescript/actions/workflows/unittests.yaml"><img src="https://github.com/AI21Labs/ai21-typescript/actions/workflows/test.yaml/badge.svg?branch=main" alt="Test"></a>
7+
<a href="https://github.com/AI21Labs/ai21-typescript/actions/workflows/integration-tests.yaml"><img src="https://github.com/AI21Labs/ai21-typescript/actions/workflows/integration-tests.yaml/badge.svg?branch=main" alt="Integration Tests"></a>
8+
<a href="https://www.npmjs.com/package/ai21" target="_blank"><img src="https://img.shields.io/npm/v/ai21?color=%2334D058&label=npm%20package" alt="Package version"></a>
9+
<a href="https://nodejs.org/" target="_blank"><img src="https://img.shields.io/badge/node->=18.0.0-brightgreen" alt="Supported Node.js versions"></a>
10+
<a href="https://github.com/semantic-release/semantic-release" target="_blank"><img src="https://img.shields.io/badge/semantic--release-typescript-e10079?logo=semantic-release" alt="Semantic Release Support"></a>
11+
<a href="https://opensource.org/licenses/Apache-2.0" target="_blank"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License"></a>
12+
</p>
13+
14+
15+
- [Installation](#Installation) 💿
16+
- [Examples](#examples-tldr) 🗂️
17+
- [AI21 Official Documentation](#Documentation)
18+
- [Chat](#Chat-Usage)
19+
- [Conversational RAG (Beta)](#Conversational-RAG-Usage)
20+
- [Files](#Files-Usage)
21+
222

323
The AI21 API Client is a TypeScript library that provides a convenient interface for interacting with the AI21 API. It abstracts away the low-level details of making API requests and handling responses, allowing developers to focus on building their applications.
424

@@ -16,7 +36,22 @@ or
1636
yarn add ai21
1737
```
1838

19-
## Usage
39+
## Examples (tl;dr)
40+
41+
If you want to quickly get a glance how to use the AI21 Python SDK and jump straight to business, you can check out the examples. Take a look at our models and see them in action! Several examples and demonstrations have been put together to show our models' functionality and capabilities.
42+
43+
### [Check out the Examples](examples/)
44+
45+
Feel free to dive in, experiment, and adapt these examples to suit your needs. We believe they'll help you get up and running quickly.
46+
47+
## Documentation
48+
49+
---
50+
51+
The full documentation for the REST API can be found on [docs.ai21.com](https://docs.ai21.com/).
52+
53+
54+
## Chat-Usage
2055

2156
To use the AI21 API Client, you'll need to have an API key. You can obtain an API key by signing up for an account on the AI21 website.
2257

@@ -46,7 +81,7 @@ The client supports streaming responses for real-time processing. Here are examp
4681
#### Using Async Iterator
4782

4883
```typescript
49-
const streamResponse = await ai21.chat.completions.create({
84+
const streamResponse = await client.chat.completions.create({
5085
model: 'jamba-1.5-mini',
5186
messages: [{ role: 'user', content: 'Write a story about a space cat' }],
5287
stream: true,
@@ -56,11 +91,11 @@ for await (const chunk of streamResponse) {
5691
console.log(chunk.choices[0]?.delta?.content || '');
5792
}
5893
```
59-
60-
### Files
94+
---
95+
### Files-Usage
6196

6297

63-
The `AI21` class provides a `files` property that gives you access to the Files API. You can use this to upload files to the AI21 Studio, which can then be utilized as context for the conversational RAG engine
98+
The `AI21` class provides a `files` property that gives you access to the Files API. You can use it to upload, retrieve, update, list, and delete files.
6499

65100

66101
```typescript
@@ -79,10 +114,26 @@ const fileUploadResponse = await client.files.create({
79114

80115
const file = await client.files.get(fileUploadResponse.fileId);
81116

117+
```
118+
119+
---
120+
### Conversational-RAG-Usage
121+
122+
123+
The `AI21` class provides a `conversationalRag` property that gives you access to the Conversational RAG API. You can use it to ask questions that are answered based on the files you uploaded.
124+
125+
126+
```typescript
127+
import { AI21 } from 'ai21';
128+
129+
const client = new AI21({
130+
apiKey: process.env.AI21_API_KEY, // or pass it in directly
131+
});
82132

83133
const convRagResponse = await client.conversationalRag.create({
84134
messages: [{ role: 'user', content: 'This question presumes that the answer can be found within the uploaded files.' }],
85135
});
136+
86137
```
87138

88139

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"name": "ai21",
3+
"engines": {
4+
"node": ">=18.0.0"
5+
},
36
"version": "1.1.0-rc.1",
47
"description": "AI21 TypeScript SDK",
58
"main": "./dist/bundle.cjs.js",

0 commit comments

Comments
 (0)