4Z API

Conversation completion (OpenAI compatible)

Endpoint: POST https://4zapi.com/v1/chat/completions

Unified OpenAI compatible portal. Select the upstream via model, for example:

  • gpt-6-luna / gpt-audio-2025-08-28 → OpenAI
  • gemini-3.8-flash → Google Gemini (compatible format)
  • For other models see GET /v1/models

OpenAI official documentation: https://platform.openai.com/docs/api-reference/chat/create

The model name format is: gpt-4-gizmo-*, and the system will automatically identify it.

For example, this GPTs: https://chatgpt.com/g/g-B3hgivKK9-write-for-me

Then its model name should be filled in as: gpt-4-gizmo-g-B3hgivKK9

List of GPTs: https://chatgpt.com/gpts

Request body (application/json)

  • messages (array<object>, required): List of conversation messages, at least one. Supports multiple rounds: system/user/assistant/tool.
  • model (string, required): The model ID to use. The gateway will select channels by token grouping, and may do model name mapping or suffix resolution (such as -thinking, -search).
  • enable_thinking (boolean): Whether to enable thinking mode (extension of this warehouse). Only the Boolean value true takes effect; choose one of extra_body.enable_thinking.
  • extra_body (object): Dialog extension parameters. Commonly used: enable_thinking; some Gemini models can use google.thinking_config, etc. Whether it takes effect depends on the channel and model.
  • frequency_penalty (number): Frequency penalty, about -2~2. Positive values ​​reduce the probability of repeating the same words.
  • logit_bias (object): Adjust the occurrence probability according to the token ID, and the value is a mapping object between -100 and 100.
  • max_completion_tokens (integer): Complete the upper limit of token (more commonly used in inference models such as o series and GPT-5). Max_tokens may be inherited when not set.
  • max_tokens (integer): The maximum number of tokens generated in this reply (common fields).
  • n (integer): Generate several assistant reply candidates for the same round of input.
  • parallel_tool_calls (boolean): Whether to allow multiple tool calls to be made in parallel in a single reply (when supported by upstream).
  • presence_penalty (number): There is a penalty, about -2~2. Positive value reduces repetition of topic expressions that have already appeared.
  • reasoning_effort (string): Inference model strength (such as low / medium / high). It can also be automatically injected by the gateway through the model name suffix.
  • response_format (object)
  • seed (number): Random seeds, try to get reproducible results under the same parameters (complete consistency is not guaranteed). Note that the field is named seed.
  • stop: Stop generation when these strings are encountered. Can be a single string or an array of strings (up to 4).
  • stream (boolean): Whether to stream output. false: Return the complete JSON at once; true: SSE incremental push, ending with data: [DONE].
  • stream_options (object)
  • temperature (number): Sampling temperature, usually 0~2. The higher the value, the more random the response is, and the lower the value, the more stable it is. Usually only one is adjusted with top_p.
  • tool_choice: Control whether to call the tool: none (not called), auto (automatic), required (must be called), or specify a function.
  • tools (array<object>): A list of tools (functions) that the model can call, used for function calling in conversations.
  • top_p (number): Kernel sampling, 0~1. Only sample tokens whose cumulative probability reaches top_p.
  • user (string): The unique identifier of the end user facilitates abuse detection and statistics on the platform side.
  • web_search_options (object)

Request example

{
  "extra_body": {
    "enable_thinking": true
  },
  "messages": [
    {
      "content": "有三个盒子,只有一个里面有奖品。你选 2 号,主持人打开 3 号(空),问要不要改选 1 号?分析并给建议。",
      "role": "user"
    }
  ],
  "model": "deepseek-v4.1-flash",
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}