Skip to content

Grok 4.6 ​

This page is generated from the upstream official OpenAPI documentation. Endpoints, parameters and examples match the official docs; brand and API domain are replaced with ModelFold.

Endpoint ​

POST /grok/v1/responses

Full URL: https://ai.modelfold.online/grok/v1/responses

Authentication: every request must include the Authorization: Bearer <API_KEY> header.

Grok 4.6 uses an OpenAI Responses–compatible endpoint (input/output items and response.* streaming events).

  • Multimodal Input — Supports mixed text, image, and file inputs in a single message.

  • Reasoning Control — Adjustable reasoning effort from low to xhigh.

  • Tools — Function calling.

Tools & tool_choice ​

The tools array enables function calling.

Function Calling

Define business functions that the model can call when needed:

json
{
  "tools": [
    {
      "type": "function",
      "name": "get_current_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location", "unit"]
      }
    }
  ],
  "tool_choice": "auto"
}

When function tools are configured in tools, set tool_choice to "auto" so the model can decide when to call them.
If you do not configure any function tools, omit the tool_choice field.

Error handling ​

Check the response body, not only the HTTP status. Errors are returned either as {"code": ..., "msg": "..."} (for example 401 invalid API key, 402 insufficient credits, 429 rate limited; the HTTP status may still be 200) or as {"error": {"type": "...", "message": "..."}}.

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesTarget model name. Allowed values: grok-4-6. 示例:grok-4-6。
streambooleanNoWhen true, responses stream in real time as server-sent events. When false, the full response is returned at once after completion. Default is true. Default:true。 示例:true。
input`stringarray<object>`Yes
reasoningobjectNoReasoning configuration for the model.
  reasoning.effortstringNoReasoning effort: low, medium, high or xhigh. If omitted, the model chooses its own effort. Set "low" for faster, cheaper answers. Reasoning tokens are billed as output tokens. Allowed values:low / medium / high / xhigh。 示例:low。
toolsarray&lt;object&gt;NoOptional tools that the model may call. Supports function calling.
textobjectYes—

Request Example ​

bash
curl -X POST "https://ai.modelfold.online/grok/v1/responses" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-4-6",
  "stream": true,
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Hello, please reply in Chinese"
        }
      ]
    }
  ],
  "text": {
    "format": {
      "type": "json_schema",
      "name": "basic_response",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "string",
            "description": "Response content"
          },
          "mood": {
            "type": "string",
            "description": "Mood when responding"
          }
        },
        "required": [
          "answer",
          "mood"
        ],
        "additionalProperties": false
      }
    }
  }
}'
json
{
  "model": "grok-4-6",
  "stream": true,
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Hello, please reply in Chinese"
        }
      ]
    }
  ],
  "text": {
    "format": {
      "type": "json_schema",
      "name": "basic_response",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "string",
            "description": "Response content"
          },
          "mood": {
            "type": "string",
            "description": "Mood when responding"
          }
        },
        "required": [
          "answer",
          "mood"
        ],
        "additionalProperties": false
      }
    }
  }
}

Response ​

200 — Request successful. ​

json
"{\n  \"output\": [\n    {\n      \"type\": \"reasoning\",\n      \"id\": \"rs_xxx\",\n      \"summary\": []\n    },\n    {\n      \"type\": \"message\",\n      \"role\": \"assistant\",\n      \"id\": \"msg_xxx\",\n      \"content\": [\n        {\n          \"type\": \"output_text\",\n          \"text\": \"Hello! How can I help you today?\"\n        }\n      ],\n      \"status\": \"completed\"\n    }\n  ],\n  \"usage\": {\n    \"total_tokens\": 4490,\n    \"output_tokens\": 47,\n    \"input_tokens\": 4443\n  },\n  \"credits_consumed\": 0.48,\n  \"status\": \"completed\"\n}"

400 — Bad request. ​

参数类型必填说明
errorobject否—
  error.messagestring否示例:Invalid request parameters。
  error.typestring否示例:invalid_request_error。
json
{
  "error": {
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}

401 — Unauthorized. ​

参数类型必填说明
errorobject否—
  error.messagestring否示例:Unauthorized。
  error.typestring否示例:authentication_error。
json
{
  "error": {
    "message": "Unauthorized",
    "type": "authentication_error"
  }
}

429 — Too many requests. ​

参数类型必填说明
errorobject否—
  error.messagestring否示例:Rate limit exceeded。
  error.typestring否示例:rate_limit_error。
json
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error"
  }
}

500 — Server error. ​

ModelFold — one API for all the best AI models.