5-minute Quick Start (Python)
1. Install
pip install openai
2. Initialize
from openai import OpenAI
client = OpenAI(
api_key="sk-your-token", # token created in the console
base_url="https://4zapi.com/v1", # Base URL
)
3. Minimal chat
resp = client.chat.completions.create(
model="gpt-6-luna", # replace with a model available in your console
messages=[
{"role": "user", "content": "Introduce API in one sentence"},
],
)
print(resp.choices[0].message.content)
4. About the response
- Success: HTTP 200, body is OpenAI-compatible JSON (with
choices)
- Failure: HTTP 4xx/5xx, or an
error field in the body (depends on the upstream format)
5. Notes
base_url must include /v1; do not drop the path prefix
- Model names follow the console and may differ from the official OpenAI IDs
- For streaming, set
stream=True; see streaming notes in the portal API Reference
- For async endpoints such as video / music, see async-task-general.md
- For online debugging, use this site's developer portal Try it / API Reference