Use environment variables #204
chenxizhang
started this conversation in
Use cases
Replies: 2 comments
-
This is a new way to define multiple environments in a single machine, and switch them in a easy way. You can create a You can switch profile by use the new {
"profiles": [
{
"name": "openai",
"api_key": "xxxx",
"model": "gpt-4o"
},
{
"name": "azure",
"endpoint": "xxxx",
"api_key": "xxxx",
"model": "gpt-4o"
},
{
"name": "kimi",
"endpoint": "https://api.moonshot.cn/v1/chat/completions",
"model": "moonshot-v1-32k",
"api_key": "xxxxx"
},
{
"name": "zhipu",
"endpoint": "https://open.bigmodel.cn/api/paas/v4/chat/completions",
"model": "glm-4",
"api_key": "xxxx"
},
{
"name": "advance",
"endpoint": "xxxxx",
"model": "gpt-4-turbo-chat-completions",
"config": {
"temperature": 0.1
},
"headers": {
"X-AppName": "PowerShell",
"X-ModelType": "{{model}}",
"X-RequestId": "{{guid}}",
"X-ScenarioGUID": "{{guid}}"
},
"auth": {
"type": "aad",
"aad": {
"tenantId": "xxxxx",
"clientId": "xxxx",
"redirectUri": "http://localhost:8400",
"scopes": [
"api://xxxx/access"
]
}
}
}
]
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can save your profile by using the simple command in the |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
When using this module, we encourage you to save some commonly used parameters (especially sensitive ones, such as keys) as environment variables, and then reference them when executing commands. For the core parameters
api_key
,endpoint
, andmodel
, we will by default read the environment variables, which are OPENAI_API_KEY, OPENAI_API_ENDPOINT, OPENAI_API_MODEL respectively. This approach simplifies your calls as much as possible.Setting Environment Variables
So how do you set environment variables? Different operating systems have different methods, please refer to the following instructions.
Windows System
You can directly enter a command like
SETX OPENAI_API_KEY your-key
in the PowerShell command window.You can also define it through a graphical interface by selecting "System" from the Control Panel, choosing "Advanced System Settings," then clicking "Environment Variables," and following the prompts to define.
MacOS System
You need to use the EXPORT command to define, refer to the introduction at https://support.apple.com/zh-cn/guide/terminal/apd382cc5fa-4f58-4449-b20a-41c53c006f8f/mac.
Linux System
Similar to MacOS, you can refer to the introduction at https://www.cnblogs.com/amboyna/archive/2008/03/08/1096024.html.
Using Environment Variables
Once you have defined the environment variables, if you want to reference them in a command call, you can use syntax like the following.
chat -api_key $env:OPENAI_API_KEY
Beta Was this translation helpful? Give feedback.
All reactions