Skip to main content

Minimal request

{
  "model": "gpt-4.1",
  "input": "Extract order fields.",
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "order",
      "schema": {
        "type": "object",
        "properties": {
          "order_id": { "type": "string" },
          "amount": { "type": "number" }
        },
        "required": ["order_id", "amount"],
        "additionalProperties": false
      }
    }
  }
}

cURL example

curl https://mass.apigo.ai/v1/responses \
  -H "Authorization: Bearer $TIDEMIND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1",
    "input": "Extract order fields.",
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "order",
        "schema": {
          "type": "object",
          "properties": {
            "order_id": { "type": "string" },
            "amount": { "type": "number" }
          },
          "required": ["order_id", "amount"],
          "additionalProperties": false
        }
      }
    }
  }'

Python example

from openai import OpenAI

client = OpenAI(
    base_url="https://mass.apigo.ai/v1",
    api_key="<TIDEMIND_API_KEY>",
)

response = client.responses.create(
    model="gpt-4.1",
    input="Extract order fields.",
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "order",
            "schema": {
                "type": "object",
                "properties": {
                    "order_id": {"type": "string"},
                    "amount": {"type": "number"},
                },
                "required": ["order_id", "amount"],
                "additionalProperties": False,
            },
        },
    },
)

print(response.output_text)

Node.js example

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://mass.apigo.ai/v1",
  apiKey: process.env.TIDEMIND_API_KEY,
});

const response = await client.responses.create({
  model: "gpt-4.1",
  input: "Extract order fields.",
  response_format: {
    type: "json_schema",
    json_schema: {
      name: "order",
      schema: {
        type: "object",
        properties: {
          order_id: { type: "string" },
          amount: { type: "number" }
        },
        required: ["order_id", "amount"],
        additionalProperties: false
      }
    }
  }
});

console.log(response.output_text);

Best practices

  • Keep schemas small and strict
  • Set additionalProperties: false on objects
  • Validate the final payload server-side even when the model follows schema well