I have created this service for using Gemini API, and trying to send request, but get this
Client error: POST https://api.gemini.com/v1/completions
resulted in a 404 Not Found
response:
{“result”:“error”,“reason”:“EndpointNotFound”,“message”:“API entry point /v1/completions
not found”}
class GeminiService
{
protected $client;
public function __construct() {
$this->client = new Client([
'base_uri' => 'https://api.gemini.com/v1/',
'headers' => [
'Authorization' => 'Bearer ' . config('gemini.api_key'),
'Content-Type' => 'application/json',
],
]);
}
public function getTextResponse($prompt) {
$response = $this->client->post('completions', [
'json' => [
'prompt' => $prompt,
'model'=> "gemini-1.5-flash"
],
]);
return json_decode($response->getBody(), true);
}
}
Can someone provide me the correct API url for this kind of calls?