Your Studio key also works from your own code. The AiX Studio API answers like OpenAI's chat completions, so most OpenAI style clients and libraries work by changing the base URL and the key. Every answer comes off your Studio credits.
The basics:
- Base URL: https://ai.resultswithkevin.com/v1
- Your key: send it as Authorization: Bearer rxs-... (create it under Your Studio key, see AiX Studio: Use Your Free Studio Key In Any ResultsAiX Plugin)
- POST /v1/chat/completions: send a messages list and get an answer
- GET /v1/models: the models you can ask for
Choosing the model:
Send model auto and the Studio picks the best value model for each request, the same way Auto works in a Studio chat. You can also send a model id from /v1/models. A model name the Studio does not offer is treated as auto.
What to send:
- messages: the usual list of system, user and assistant messages.
- max_tokens (or max_completion_tokens): room for the answer, up to 16,000. Every request gets at least 1,024, because some models think before they answer. You only pay for what is really used.
- response_format with type json_object: the AI is told to reply with valid JSON only.
- stream: true is accepted. The whole answer arrives as one chunk, then a last chunk with the usage, then [DONE].
What comes back:
The answer has the same shape as OpenAI's: choices with the message, a finish_reason, and usage with prompt_tokens, completion_tokens and total_tokens. The usage also holds credits_used and credits_left.
Three headers come with every answer:
- X-RXS-Credits-Used: the credits this answer used
- X-RXS-Credits-Left: the credits you have left
- X-RXS-Model: the model that answered
Limits:
- 30 answers a minute per key.
- 60 answers a minute per member, all keys together.
- The monthly limit you set on a key in the Studio, if any.
A request over the per minute limit gets status 429. Wait a moment and send it again.
Messages you may see:
- 401: no key was sent, the key is not right, or it is switched off. The message says which.
- 402: the key reached its monthly limit, or there are not enough Studio credits.
- 404: the address is wrong. Use POST /v1/chat/completions or GET /v1/models.
- 502: the AI did not answer. The message keeps the first sentence of the reason. Try again.
A real example:
A developer at yoursite.com points an OpenAI style client at https://ai.resultswithkevin.com/v1, sets the API key to the Studio key named yoursite.com app, and sends model auto with one user message: Write three subject lines for a spring sale. The answer comes back with the usual choices list, and the X-RXS-Credits-Used header shows what it cost in credits.
Tips:
- Use one key per app, so the Your Studio key screen shows what each one uses.
- Set a monthly limit on a key you use in testing.
- Keep the key on your server. Never put it in a web page or app that other people can open.