Moving an app from a direct AI account to the AI gateway: what to change, step by step

All in One AIUsing the AI API·· 7 views· 2 min read

Do you have a program that already talks directly to an AI company and want to move it to the Interweb gateway? In most cases the change is small. This is the order we recommend.

Step by step

1 Create a sandbox_ key in the API Center, with ai:read and ai:write, and keep it in an environment variable, INTERWEB_API_KEY.
2 Change the base URL to api.interweb.ao/v1. In the OpenAI SDK it is base_url. For coding tools, follow the article for each one.
3 Change the model name to an id from our catalog. Our ids always have a slash, such as deepseek-ai/deepseek-v4-flash. A name without a slash gives 404 model_not_found.
4 Run the program with the sandbox_ key. Chat answers "Resposta de teste (sandbox)." and spends nothing: it confirms the address, the key and the format are right.
5 Buy credits, switch to the prod_ key and make a small real request, with a low max_tokens.

What may need more care

If your program uses What to do
Streaming Ask for stream_options with include_usage. Without it, the whole credit reservation stays charged.
Requests without max_tokens Always set max_tokens. Without it, we reserve 4096 output tokens, and with a low balance that gives 402.
Images through the OpenAI SDK Images, videos and voice use POST /v1/media/generations, with plain HTTP requests.
Tools (function calling) They work in chat, but check that the chosen model accepts them. See sending tools in a chat request.
Error handling Errors carry code and message inside error. Add 402 insufficient_credits and 429 rate_limited, which comes with the Retry-After header.
Make the change through environment variables (address, key and model), not in the code. That way you can go back in a minute if you need to. See how to change models without touching your code.

Ready to move? Create the key and open All in One AI.

See All in One AI

SEE ALSO

Using the OpenAI SDK

Why every model id has a slash

The AI API errors

All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.59/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.

Powered by WHMCompleteSolution