forked from phoenix/litellm-mirror
update proxy api docs
This commit is contained in:
parent
5acd1c9d47
commit
6fbd01e715
2 changed files with 49 additions and 19 deletions
|
@ -1,5 +1,4 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
|
||||
const CodeBlock = ({ token }) => {
|
||||
const codeWithToken = `${token}`;
|
||||
|
@ -15,20 +14,37 @@ const TokenGen = () => {
|
|||
const [token, setToken] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const generateToken = () => {
|
||||
// Generate a special uuid/token "sk-litellm-<uuid>"
|
||||
const newToken = `sk-litellm-${uuidv4()}`;
|
||||
setToken(newToken);
|
||||
};
|
||||
const generateToken = async () => {
|
||||
try {
|
||||
const response = await fetch('https://proxy.litellm.ai/key/new', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer sk-liteplayground',
|
||||
},
|
||||
body: JSON.stringify({'total_budget': 100})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
generateToken();
|
||||
}, []);
|
||||
setToken(`${data.api_key}`);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch new token: ', error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<CodeBlock token={token} />
|
||||
</div>
|
||||
);
|
||||
generateToken();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<CodeBlock token={token} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TokenGen;
|
||||
export default TokenGen;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue