This example sends a direct Gemini 3 chat request from Node.js through APIDot.
- Loading
APIDOT_API_KEYfrom the environment or the repo-root.envfile. - Calling the Gemini Native endpoint with the model ID in the URL path.
- Handling non-2xx and API-level errors explicitly.
- Printing the response JSON.
- Node.js 18 or newer.
- An APIDot API key stored server-side.
- No npm dependencies are required.
Use placeholders only. Do not commit real credentials.
APIDOT_API_KEY=YOUR_API_KEY_HEREcd node/gemini-3
cp ../../.env.example ../../.env
# Edit ../../.env and set APIDOT_API_KEY
npm startShortened response:
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Here is a concise launch checklist..."
}
]
},
"finishReason": "STOP"
}
]
}- Keep APIDot API keys in server-side environment variables.
- Put the Gemini model ID in the URL path.
- Set request timeouts in your backend HTTP client.
- Log model names and application context, but never log API keys.
- Validate user input before sending it to the model.
- Committing a real API key or
.envfile. - Sending APIDot API keys from browser code.
- Putting the Gemini model ID in the body instead of the URL path.
- Adding async
task_idpolling to this direct chat request. - Assuming every response contains at least one candidate.
- cURL quickstart: ../../curl/chat/gemini-3.md
- Gemini 3 docs: https://apidot.ai/docs/gemini-3
- Chat models: https://apidot.ai/models/chat
- Gemini 3 landing page: https://apidot.ai/models/gemini-3