
example.mjs. Keep the API key in an environment variable; do not expose it in browser JavaScript.
instructions field. Browse the model catalog for supported model IDs.
The response uses the standard Chat Completions shape. The generated text is in choices[0].message.content, and usage data is in response.usage.
If the request fails, check the API key, organization balance, model ID, and system prompt first. For endpoint-specific fields, see the Chat Completions reference.
