forked from phoenix/litellm-mirror
docs(user_keys.md): add openai js example to docs
This commit is contained in:
parent
6bf60d773e
commit
fe6ea9f892
2 changed files with 28 additions and 1 deletions
|
@ -226,7 +226,7 @@ general_settings:
|
|||
|
||||
Allow developers to call the proxy with Anthropic/boto3/etc. client sdk's.
|
||||
|
||||
Use our [Anthropic Adapter](https://github.com/BerriAI/litellm/blob/fd743aaefd23ae509d8ca64b0c232d25fe3e39ee/litellm/adapters/anthropic_adapter.py#L50) for reference
|
||||
Test our [Anthropic Adapter](../anthropic_completion.md) for reference [**Code**](https://github.com/BerriAI/litellm/blob/fd743aaefd23ae509d8ca64b0c232d25fe3e39ee/litellm/adapters/anthropic_adapter.py#L50)
|
||||
|
||||
### 1. Write an Adapter
|
||||
|
||||
|
|
|
@ -206,6 +206,33 @@ console.log(message);
|
|||
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="openai JS" label="OpenAI JS">
|
||||
|
||||
```js
|
||||
const { OpenAI } = require('openai');
|
||||
|
||||
const openai = new OpenAI({
|
||||
apiKey: "sk-1234", // This is the default and can be omitted
|
||||
baseURL: "http://0.0.0.0:4000"
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const chatCompletion = await openai.chat.completions.create({
|
||||
messages: [{ role: 'user', content: 'Say this is a test' }],
|
||||
model: 'gpt-3.5-turbo',
|
||||
}, {"metadata": {
|
||||
"generation_name": "ishaan-generation-openaijs-client",
|
||||
"generation_id": "openaijs-client-gen-id22",
|
||||
"trace_id": "openaijs-client-trace-id22",
|
||||
"trace_user_id": "openaijs-client-user-id2"
|
||||
}});
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="instructor" label="Instructor">
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue