All ideas

Provide OpenAI-compatible API

Purpose By implementing this approach, you won’t need to modify the code for each different LLM provider manually. Most major AI companies, such as Claude (Anthropic), Google Gemini, Grok and DeepSeek, and others, offer OpenAI-compatible APIs. Extra configuration To enhance flexibility and reduce the need for frequent code updates, consider allowing users to configure the following options within the app: API Key (api_key) Base URL (base_url) Model Name (model) Code Example Instead of hardcoding these values, you can update your implementation to dynamically accept user-provided settings, like this: post($base_url . "chat/completions", [ 'headers' => [ 'Authorization' => "Bearer $api_key", 'Content-Type' => 'application/json', ], 'json' => [ 'model' => $model, 'messages' => [ ['role' => 'system', 'content' => 'You are a helpful assistant.'], ['role' => 'user', 'content' => 'Explain to me how AI works'] ], 'temperature' => 0.7 ] ]); $responsedata = jsondecode($response->getBody(), true); echo $response_data'choices''message'; ?> What to Change In Your Code you could just change the class, APIClient in src/php/Translator/OpenAI/APIClient.php. let user fill in line 49 and 80 instead of the constant value. maybe create a bar for user to fill in in setting. More Information please refer to the documentation of OpenAI compatible API Gemini: https://ai.google.dev/gemini-api/docs/openai Claude: https://docs.anthropic.com/en/api/openai-sdk grok: https://docs.x.ai/docs/overview#migrating-from-another-llm-provider List Of Provider And Model If you are going to support more LLM provider and model in the future, the list and source code may help you. This is Cline, an open source for code. link: https://github.com/cline/cline/blob/main/src/shared/api.ts i like your work, and it will be perfect if the addon provide api for grok and claude. i believe OpenAI-compatible API can reduce your workload to support most of the api.

Activity · 6
elaping5691
elaping56911y
Cline Sample the picture is the sample in cline. When I choose OpenAI Compatible, I only need to fill in Base URL, API Key and Model ID. with OpenAI Compatible API, I can choose Claude (Anthropic), Google Gemini, Grok and DeepSeek, and others easily. Base URL List: Claude (Anthropic): "https://api.anthropic.com/v1/" Google Gemini: "https://generativelanguage.googleapis.com/v1beta/openai/" Grok: "https://api.x.ai/v1" DeepSeek: "https://api.deepseek.com"
elaping5691
changed description "Purpose By implementing this approach, you won’t need to modify the code for each different LLM provider manually. Most major AI companies, such as Claude (Anthropic), Google Gemini, Grok and DeepSeek, and others, offer OpenAI-compatible APIs. Extra configuration To enhance flexibility and reduce the need for frequent code updates, consider allowing users to configure the following options within the app: API Key (apikey) Base URL (baseurl) Model Name (model) Code Example Instead of hardcoding these values, you can update your implementation to dynamically accept user-provided settings, like this: import <?php require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); $api_key = "GEMINI_API_KEY"; $base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"; $model = "gemini-2.0-flash"; $response = $client->post($base_url . "chat/completions", [ 'headers' => [ 'Authorization' => "Bearer $api_key", 'Content-Type' => 'application/json', ], 'json' => [ 'model' => $model, 'messages' => [ ['role' => 'system', 'content' => 'You are a helpful assistant.'], ['role' => 'user', 'content' => 'Explain to me how AI works'] ], 'temperature' => 0.7 ] ]); $response_data = json_decode($response->getBody(), true); echo $response_data'choices''message'; ?> What to Change In Your Code you could just change the class, API_Client in src/php/Translator/OpenAI/API_Client.php. let user fill in line 49 and 80 instead of the constant value. maybe create a bar for user to fill in in setting. More Information please refer to the documentation of OpenAI from "openai"; const openai = new OpenAI({ apiKey: "USERPROVIDEDAPIKEY", baseURL: "USERPROVIDEDBASEURL", }); const response = await openai.chat.completions.create({ model: "USERPROVIDEDMODEL", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Explain to me how AI works.", }, ], }); console.log(response.choices[0].message); More Information please refer to the documentation of OpenAI compatible API Gemini: https://ai.google.dev/gemini-api/docs/openai Claude: https://docs.anthropic.com/en/api/openai-sdk grok: https://docs.x.ai/docs/overview#migrating-from-another-llm-provider List Of Provider And Model If you are going to support more LLM provider and model in the future, the list and source code may help you. This is Cline, an open source for code. link: https://github.com/cline/cline/blob/main/src/shared/api.ts i like your work, and it will be perfect if the addon provide api for grok and claude. i believe OpenAI-compatible API can reduce your workload to support most of the api. "
· 1y
Robbert Vermeulenmarked this as under-review· 1y
Robbert Vermeulen
Robbert Vermeulen1y
Thank you for this feature request and additional information. We will review it and see if it is worth implementing in the short term.
adrian
adrian1y
Upvoting this. Google Gemini models are getting better and better with a reasonable free token allocation.
Robbert Vermeulen
Robbert Vermeulen1y
@elaping5691 Thank you for this feature request. I will consider it although I am thinking about some kind of "YOLO" mode in the plugin, where users like you can do stuff on their own at their own risk. What do you think of that? Because not every users wants al these different models or adjustments.
Robbert Vermeulenmarked this as planned· 1y
swtung
swtung1y
it will be very useful
atmaxfr
atmaxfr1y
Maybe add openrouter API and let us choose whatever LLM we want to work with... 1 API to rule them all ;-)

More in Feature