Skip to content

feat: API Host代理配置 #49

@Ace-Radom

Description

@Ace-Radom

这是一个在别的一些chatgpt项目里普遍存在的一个功能 我觉得也可以加到这里来

https://github.com/justjavac/openai-proxy

因为这个项目以及其他一些代理项目的存在 有一些处在国外的服务器在为国内的用户提供无需全局代理的API转接服务
也就是更改API的Host到他们提供的域名上 这些网站会把所有请求原封不动转发给openai官方api 随后收到回复后再转回用户
这样的好处是这些服务器是位于国外的而且不会被GFW影响 同时也不会被openai封锁账户停用

我在隔壁也实现了这样的功能:

openai -> host = OPENAI_HOST;
openai -> endpoint = ( char* ) malloc( 256 );
sprintf( openai -> endpoint , "%s/v1/chat/completions" , openai -> host );
openai -> subscription_endpoint = ( char* ) malloc( 256 );
sprintf( openai -> subscription_endpoint , "%s/dashboard/billing/subscription" , openai -> host );
openai -> usage_endpoint = ( char* ) malloc( 256 );
sprintf( openai -> usage_endpoint , "%s/dashboard/billing/usage" , openai -> host );

实现方法也很简单 在 ChatGPT 类内新增一个成员变量存放使用的Host 然后基于这个Host在后面加上类似于 /v1/chat/completions 之类的endpoint来得到API地址

你可以考虑一下

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeatNew request on features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions