-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About the /v1/models
and /v1/models/:model
interfaces and config.json for claude via proxy.
#71
Comments
/v1/models
and /v1/models/:model
interfaces.
hi,You don't need a colon. use this:
|
Thank you for your tip. Anyway, it seems that the document needs to be fixed: BTW, how to set the $ cat config.json
{
"debug": false,
"load_balancing": "random",
"proxy":{
"type":"http",
"http_proxy": "http://127.0.0.1:8080",
"strategy": "default"
},
"services": {
"claude": [
{
"models": ["claude-3-5-sonnet-20240620"],
"enabled": true,
"credentials": {
"api_key": "my-claude-api-key"
},
"server_url":"https://api.anthropic.com/v1/messages",
"use_proxy":true
}
],
"openai": [
{
"models": ["chatgpt-4o-latest"],
"enabled": true,
"credentials": {
"api_key": "my-openai-api-key"
},
"server_url":"https://api.gptsapi.net/v1/chat/completions"
}
]
}
}
|
For Claude's configuration, theoretically, this setup should work. If there are any issues, you can provide the error log information from the backend calls.
|
/v1/models
and /v1/models/:model
interfaces./v1/models
and /v1/models/:model
interfaces and config.json for claude via proxy.
See the following for more details: The content of
The command to run werner@x13dai-t:~/Public/repo/github.com/fruitbars$ ./simple-one-api.git/simple-one-api config_claude.json
2024/09/09 22:10:37 config.go:188: config name: /home/werner/Public/repo/github.com/fruitbars/config_claude.json
2024/09/09 22:10:37 config.go:197: config_claude json
2024/09/09 22:10:37 config.go:225: { false {default http http://127.0.0.1:8080 0} 123456 random [] map[] map[] map[claude:[{ [claude-3-5-sonnet-20240620] true map[api_key:my-claude-api-key] [] https://api.anthropic.com/v1/messages map[] map[] {0 0 0 0 0} 0xc00044370e 0}]] {false 0 0} false []}
2024/09/09 22:10:37 config.go:238: {default http http://127.0.0.1:8080 0}
2024/09/09 22:10:37 config.go:246: read LoadBalancingStrategy ok, random
2024/09/09 22:10:37 config.go:254: read ServerPort ok, :9090
2024/09/09 22:10:37 config.go:259: log level:
2024/09/09 22:10:37 config.go:119: Models: [claude-3-5-sonnet-20240620], service Timeout:0,Limit Timeout: 0, QPS: 0, QPM: 0, RPM: 0,Concurrency: 0
2024/09/09 22:10:37 config.go:268: GlobalModelRedirect: map[]
2024/09/09 22:10:37 config.go:397: other support models: [claude-3-5-sonnet-20240620]
2024/09/09 22:10:37 config.go:275: SupportMultiContentModels: [gpt-4o gpt-4-turbo glm-4v gemini-* yi-vision gpt-4o*]
2024/09/09 22:10:37 initializer.go:24: config.InitConfig ok
2024/09/09 22:10:37 logger.go:14: level mode
2024/09/09 22:10:37 logger.go:31: level mode default prod
2024/09/09 22:10:37 logger.go:47: log plain-text format
2024/09/09 22:10:37 initializer.go:31: config.LogLevel ok
2024-09-09T22:10:37.784+0800 WARN simple-one-api.git/main.go:63 check EnableWeb config {"config.GSOAConf.EnableWeb": false} The curl test works as follows: $ curl http://127.0.0.1:9090/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer 123456" -d '{
"model": "claude-3-5-sonnet-20240620",
"messages": [{"role": "user", "content": "Hello, GPT-4!"}],
"max_tokens":1024}'
{"id":"msg_01DybG9mpASVtLDiQCCXuC5S","object":"message","created":1725931067,"model":"claude-3-5-sonnet-20240620","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! It's nice to meet you. How can I assist you today? Feel free to ask me any questions or let me know if you need help with anything."},"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":14,"completion_tokens":37,"total_tokens":51}} But the test in The corresponding stdout log of
|
I've created #73 which will fix the above problem, as shown below: $ curl http://127.0.0.1:9090/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer 123456" -d '{
"model": "claude-3-5-sonnet-20240620",
"messages": [{"role": "user", "content": "Hello, GPT-4!"}],
"max_tokens":1024}'
{"id":"msg_01SFC3tbYGjLsQ4nBzcMJooL","object":"message","created":1725936330,"model":"claude-3-5-sonnet-20240620","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! It's nice to meet you. How can I assist you today? Feel free to ask me any questions or let me know if you need help with anything."},"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":14,"completion_tokens":37,"total_tokens":51}} |
I tried as follows, but still failed:
On the other hand, if my model name contains a "/", such as "claude.ai/claude-3-5-sonnet-20240620", it would make the URL very strange. Therefore, I think this call method has no practical value. |
I'm running simple-one-api with the following config file:
I can confirm it's working:
Then I tried to access the model via the /v1/models/:model interface as follows but failed:
So, how to use the
/v1/models
and/v1/models/:model
interfaces as the access endpoints?Regards,
Zhao
The text was updated successfully, but these errors were encountered: