Send your first request with a free AI API
Create a WhatOTP API key, connect the OpenAI SDK, and send your first GPT 6 Astra request. Includes setup, working code, and troubleshooting steps.
What is an AI API?
An AI API lets your application send messages to a model over HTTP and receive a response. For a chat interface, text summarizer, or writing assistant, this separates the model infrastructure from your application. The essential integration settings are the service URL, API key, and model name.
WhatOTP offers the Chat Completions format. gpt-6-astra is the platform’s public model alias; the underlying model and availability depend on the provider connected by an administrator. Check the status page for an active connection before getting started.
1. Create your account and API key
Sign in to your free account and open API keys in the dashboard. Create a key with a recognizable project name. The full key is shown only when it is created, so save it in a server environment variable.
Set WHATOTP_API_KEY to your key and WHATOTP_BASE_URL to your WhatOTP API root ending in /v1. A local example is http://localhost:3000/v1. For a deployed project, use your actual service domain.
- Keep the key out of JavaScript sent to the browser.
- Use separate keys for development and production projects.
- Restart your application server after changing environment variables.
2. Send a request with the OpenAI SDK
Run npm install openai in your Node.js project. Use the following example in a server-side file. The SDK sends the request to your configured baseURL; use a WhatOTP key rather than a key issued for an OpenAI account.
The messages array contains the conversation sent to the model. One user message is enough for an initial test. Read the response from message.content in the first choices entry. If the request fails, handle the SDK error before trying to read response content.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.WHATOTP_API_KEY,
baseURL: process.env.WHATOTP_BASE_URL,
});
const response = await client.chat.completions.create({
model: "gpt-6-astra",
messages: [{ role: "user", content: "Hello, Astra!" }],
});
console.log(response.choices[0]?.message.content);3. Check the result and usage
Open request history to inspect the status code, selected model, and response time. A ≈ beside token usage indicates an estimate instead of a precise count reported by the provider. Checking the error code before retrying helps avoid unnecessary traffic.
For 401 errors, check your key and account status. For 400, review the model name and request fields. A 503 can mean no provider is connected or model access is paused. A labeled demo response in Playground does not confirm that live API access works.
Turn a working connection into a product
After your first response, add a loading state, useful error messages, and a retry option. Streaming can make a chat experience feel more responsive. The documentation lists supported request fields and error codes.
This release does not apply platform usage fees or daily request/token quotas. Connected providers can still impose limits, and technical capacity affects availability. Design your application around that possibility instead of assuming every request will finish in the same amount of time.