Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Added doc for automatic pull of env variable of client
Browse files Browse the repository at this point in the history
  • Loading branch information
willhama committed Dec 20, 2023
1 parent 692ac86 commit 021d394
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ listModels.forEach((model) => {
```typescript
const chatStreamResponse = await client.chatStream({
model: 'mistral-tiny',
messages: [{ role: 'user', content: 'What is the best French cheese?' }],
messages: [{role: 'user', content: 'What is the best French cheese?'}],
});

console.log('Chat Stream:');
Expand All @@ -54,7 +54,7 @@ for await (const chunk of chatStreamResponse) {
```typescript
const chatResponse = await client.chat({
model: 'mistral-tiny',
messages: [{ role: 'user', content: 'What is the best French cheese?' }],
messages: [{role: 'user', content: 'What is the best French cheese?'}],
});

console.log('Chat:', chatResponse.choices[0].message.content);
Expand Down Expand Up @@ -97,7 +97,7 @@ Get your own Mistral API Key: <https://docs.mistral.ai/#api-access>
MISTRAL_API_KEY='your_api_key' node chat_with_streaming.js
```

### Persisting API key in command line tool
### Persisting the API key in environment

Set your Mistral API Key as an environment variable. You only need to do this once.

Expand All @@ -114,3 +114,10 @@ You can then run the examples without appending the API key:
```bash
node chat_with_streaming.js
```
After the env variable setup the client will find the `MISTRAL_API_KEY` by itself

```typescript
import MistralClient from '@mistralai/mistralai';

const client = new MistralClient();
```

0 comments on commit 021d394

Please sign in to comment.