forked from unkeyed/unkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow setting X-Base-URL header (unkeyed#1870)
* feat: allow setting X-Base-URL header * feat: allow setting X-Base-URL header * fix(docs): correct X-Min-Similarity value to 0.92 in settings.mdx
- Loading branch information
Showing
4 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: Settings | ||
description: Configure the behavior of the semantic cache | ||
--- | ||
|
||
|
||
## Customizing the base URL | ||
|
||
By default, the semantic cache will forward requests to the OpenAI API at `https://api.openai.com/v1`. | ||
|
||
You can customize this, if you want to use a different LLM API or have a different base URL. | ||
|
||
To do so, set the `X-Base-Url` header when sending requests to the cache: | ||
|
||
``` | ||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY, | ||
baseURL: "https://<gateway>.llm.unkey.io", | ||
defaultHeaders: { | ||
'X-Base-Url': 'https://api.openai.com/v2' | ||
} | ||
}); | ||
``` | ||
|
||
## Similarity threshold | ||
|
||
By default, the semantic cache will return a HIT if a previous response is found with a similarity score of 0.9 or above. | ||
|
||
You can customize this, if you want to increase cache hit ratio and/or have a higher standard for returning cached responses. | ||
|
||
To do so, set the `X-Min-Similarity` header when sending requests to the cache: | ||
|
||
``` | ||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY, | ||
baseURL: "https://<gateway>.llm.unkey.io", | ||
defaultHeaders: { | ||
'X-Min-Similarity': 0.92 | ||
} | ||
}); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters