forked from phoenix/litellm-mirror
docs js spend tracking with tags
This commit is contained in:
parent
b9fab4bd4d
commit
89922ab71f
1 changed files with 42 additions and 3 deletions
|
@ -138,8 +138,6 @@ print(response)
|
||||||
|
|
||||||
<TabItem value="openai js" label="OpenAI JS">
|
<TabItem value="openai js" label="OpenAI JS">
|
||||||
|
|
||||||
Set `extra_body={"metadata": { }}` to `metadata` you want to pass
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const openai = require('openai');
|
const openai = require('openai');
|
||||||
|
|
||||||
|
@ -158,7 +156,9 @@ async function runOpenAI() {
|
||||||
content: "this is a test request, write a short poem"
|
content: "this is a test request, write a short poem"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
tags: ["model-anthropic-claude-v2.1", "app-ishaan-prod"] // 👈 Key Change
|
metadata: {
|
||||||
|
tags: ["model-anthropic-claude-v2.1", "app-ishaan-prod"] // 👈 Key Change
|
||||||
|
}
|
||||||
});
|
});
|
||||||
console.log(response);
|
console.log(response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -306,6 +306,45 @@ print(response)
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
|
||||||
|
<TabItem value="openai js" label="OpenAI JS">
|
||||||
|
|
||||||
|
```js
|
||||||
|
const openai = require('openai');
|
||||||
|
|
||||||
|
async function runOpenAI() {
|
||||||
|
const client = new openai.OpenAI({
|
||||||
|
apiKey: 'sk-1234',
|
||||||
|
baseURL: 'http://0.0.0.0:4000'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await client.chat.completions.create({
|
||||||
|
model: 'gpt-3.5-turbo',
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: 'user',
|
||||||
|
content: "this is a test request, write a short poem"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
metadata: {
|
||||||
|
spend_logs_metadata: { // 👈 Key Change
|
||||||
|
hello: "world"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("got this exception from server");
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the asynchronous function
|
||||||
|
runOpenAI();
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
<TabItem value="Curl" label="Curl Request">
|
<TabItem value="Curl" label="Curl Request">
|
||||||
|
|
||||||
Pass `metadata` as part of the request body
|
Pass `metadata` as part of the request body
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue