Taewan-P/gpt_mobile

Third-party API calls(타사 API 호출)

Closed this issue · 3 comments

Hello developers! If I want to use other third-party APIs to replace the official OpenAI call address, where should I change it in your project?
안녕하세요 개발자 여러분! 다른 타사 API를 사용하여 공식 OpenAI 호출 주소를 대체하려면 프로젝트의 어디에서 변경해야 합니까?

Hi,
To replace the official OpenAI call address, you should look at app/src/main/kotlin/dev/chungjungsoo/gptmobile/data/repository/ChatRepositoryImpl.kt#L48.

Note that this projects uses unofficial OpenAI library written in Kotlin for OpenAI API calls. For raw api calls, check out how Anthropic APIs are called in the same file since I implemented it.

你好, 要替换官方 OpenAI 调用地址,你应该看看app/src/main/kotlin/dev/chungjungsoo/gptmobile/data/repository/ChatRepositoryImpl.kt#L48

请注意,该项目使用非官方的 OpenAI 库(以 Kotlin 编写)进行 OpenAI API 调用。对于原始 API 调用,请查看自我实现以来,Anthropic API 是如何在同一文件中调用的。

Thank you for your reply! I checked the code you pointed out, but I didn't find the specific replacement API address. Are you calling the OpenAI official API address through https://api.openai.com?

but I didn't find the specific replacement API address.

See what is initialized in L50, then look at this code. Initialize a OpenAIHost, then set its baseUrl with your API.

openai-kotlin/openai-client/src/commonMain/kotlin/com.aallam.openai.client/OpenAI.kt#L36

openAI = OpenAI(platform.token ?: "", host = OpenAIHost(baseUrl = "https://..."))

By default, it uses OpenAIHost.OpenAI, which is a companion object declared in OpenAIConfig#L100, so yes it is an official API address.