Skip to content

OpenAI-Compatible API: Base URL, Models & Keys

For a Token Cloud workflow that connects model APIs and tracks token usage, start with an OpenAI-compatible client. Set the API base URL to https://api.token4ai.cloud/v1, provide a Token4AI API key, and choose a model ID available to that key. Then test a small request and verify it in the console.

By the Token4AI Cloud product team

Before you connect

  1. Sign in to the Token4AI console and check the account balance and current model access.
  2. Create an API key for your application. Store the secret in a server environment variable or a secret manager.
  3. Configure the client’s base URL as https://api.token4ai.cloud/v1. Some tools ask for the host separately; follow that tool’s URL format to avoid adding /v1 twice.

Discover the model IDs your key can access

Set TOKEN4AI_API_KEY in your local shell or deployment secrets, then run this model-list request. This example discovers available models; it does not generate model output.

Read the returned IDs and select one that supports the request type your application needs. Availability can change, so use the current response rather than a hardcoded example model.

curl https://api.token4ai.cloud/v1/models \
  -H "Authorization: Bearer $TOKEN4AI_API_KEY"

Send and inspect a first request

In your client, use the configured base URL, key and selected model ID to send a short prompt through a supported endpoint. Model generation consumes account credit according to the current billing rules.

Open usage history in the console to inspect the result. Confirm the model, request status, latency and token consumption before increasing traffic. For streaming, also check that your client handles incremental output and interruptions correctly.

Troubleshoot common connection failures

  1. 401: check that you used a current Token4AI API key and included the expected authorization header.
  2. 403: check the key permissions and account access for the requested operation.
  3. Unknown model: refresh the model list and copy the exact ID.
  4. 429: reduce concurrency and use bounded retries. Rate limiting may occur at different points in the request path; retain the request ID for support.

Keep application credentials private

Do not embed a secret API key in a public webpage, browser bundle or shared screenshot. Route requests through your own server when building a public web application. Revoke a key if it is exposed.

Compatibility covers supported API operations, not every feature in every provider SDK. Consult the documentation and test any specialized request fields your workflow depends on.

Keep reading