4Z API

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

  1. base_url must include /v1; do not drop the path prefix
  2. Model names follow the console and may differ from the official OpenAI IDs
  3. For streaming, set stream=True; see streaming notes in the portal API Reference
  4. For async endpoints such as video / music, see async-task-general.md
  5. For online debugging, use this site's developer portal Try it / API Reference