Table of contents
Official Content
  • This documentation is valid for:

This API provides access to the Responses endpoint from Globant Enterprise AI. It includes plain text inputs, function calling, and file inputs (PDFs and images).

Check the Glob.AI OS API Reference for generic variables needed to use the API.

Note: This endpoint currently supports only OpenAI models.

Endpoint

Method Path
POST /responses

This endpoint has the same interface (Request/Response) as the OpenAI Responses API.

1. Basic text completion

Request

curl -X POST "$BASE_URL/responses" \
  -H "Authorization: Bearer $SAIA_APITOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/o1-pro",
    "input": "Tell me a three‑sentence bedtime story about a unicorn.",
    "stream": false,
    "max_tokens": 2000
}'


Expected Response

{
    "instructions": null,
    "metadata": {},
    "reasoning": {
        "effort": "medium"
    },
    "usage": {
        "completion_tokens": 272,
        "prompt_tokens": 18,
        "total_cost": 0.1659,
        "completion_tokens_details": {
            "reasoning_tokens": 192
        },
        "prompt_tokens_details": {
            "cached_tokens": 0
        },
        "total_tokens": 290,
        "currency": "USD",
        "completion_cost": 0.1632,
        "prompt_cost": 0.0027
    },
    "created_at": 1746473821,
    "error": null,
    "tools": [],
    "output": 
        {
            "summary": [,
            "id": "rs_6819...",
            "type": "reasoning",
            "status": null
        },
        {
            "role": "assistant",
            "id": "msg_68191...",
            "type": "message",
            "content": 
                {
                    "annotations": [,
                    "text": "Once upon a time, in a hidden meadow where flowers swayed like colored ribbons, a unicorn named Moonlight pranced gracefully beneath the twinkling stars. By day, she roamed among the sun-kissed hills, her soft mane shimmering with every gentle breeze. At night, Moonlight’s silvery horn glowed softly, granting sweet, soothing dreams to all who believed in magic.",
                    "type": "output_text"
                }
            ],
            "status": "completed"
        }
    ],
    "top_p": 1,
    "previous_response_id": null,
    "parallel_tool_calls": true,
    "temperature": 1,
    "tool_choice": "auto",
    "model": "o1-pro-2025-03-19",
    "id": "resp_bGl...",
    "text": {
        "format": {
            "type": "text"
        }
    },
    "incomplete_details": null,
    "truncation": "disabled",
    "user": null,
    "object": "response",
    "max_output_tokens": null,
    "status": "completed"
}

2. Function calling

Request

curl -X POST "$BASE_URL/responses" \
  -H "Authorization: Bearer $SAIA_APITOKEN" \
  -H "Content-Type: application/json" \
  -d '{
   "model": "openai/o1-pro",
    "input": "What is the weather like in Paris today?",
    "tools": 
        {
            "type": "function",
            "name": "get_weather",
            "description": "Get current temperature for a given location.",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City and country e.g. Bogotá, Colombia"
                    }
                },
                "required": [
                    "location"
                ,
                "additionalProperties": false
            }
        }
    ]
}'


Expected Response

{
    "instructions": null,
    "metadata": {},
    "reasoning": {
        "effort": "medium"
    },
    "usage": {
        "total_tokens": 0,
        "currency": "USD"
    },
    "created_at": 1745243167,
    "error": null,
    "tools": 
        {
            "name": "get_weather",
            "description": "Get current temperature for a given location.",
            "strict": true,
            "type": "function",
            "parameters": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                    "location": {
                        "description": "City and country e.g. Bogotá, Colombia",
                        "type": "string"
                    }
                },
                "required": [
                    "location"
                
            }
        }
    ],
    "output": 
        {
            "summary": [,
            "id": "rs_6806...",
            "type": "reasoning",
            "status": null
        },
        {
            "name": "get_weather",
            "arguments": "{\"location\":\"Paris, France\"}",
            "id": "fc_6806...",
            "type": "function_call",
            "call_id": "call_ruYPRIF9qcOxft5XrfjCBQg8",
            "status": "completed"
        }
    ],
    "top_p": 1,
    "previous_response_id": null,
    "parallel_tool_calls": true,
    "temperature": 1,
    "tool_choice": "auto",
    "model": "o1-pro-2025-03-19",
    "id": "resp_6806...",
    "text": {
        "format": {
            "type": "text"
        }
    },
    "incomplete_details": null,
    "truncation": "disabled",
    "user": null,
    "object": "response",
    "max_output_tokens": null,
    "status": "completed"
}

3. Sending files

3.1 Image input

There are two ways to attach an image:

  • URL – pass a publicly reachable image_url. Recommended when the file is already hosted and you want a minimal payload.
  • Base‑64 inline – embed the binary data in a data:image/...;base64, URI. Recommended for local files, private content, or CI pipelines with no public storage.


Option A — Public image URL (cURL)

curl -X  POST "$BASE_URL/responses" \
  -H "Authorization: Bearer $SAIA_APITOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1",
    "input": 
      {
        "role": "user",
        "content": [
          {"type": "input_text",  "text": "What is in this image?"},
          {
            "type": "input_image",
            "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
          }
        
      }
    ]
  }'


Option B — Inline base‑64 (Python)

import base64, json, requests

token = "SAIA_APITOKEN"
url   = "$BASE_URL/responses"
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}

def encode_file(file_path):
    with open(file_path, 'rb') as file:
        return base64.b64encode(file.read()).decode('utf-8')

file_path = "/path/to/your/image.png"
encoded_file = encode_file(file_path)

payload = {
    "model": "openai/gpt-4.1",
    "input":  
        {
            "role": "user",
            "content": [{
                "type": "input_text",
                "text": "What's this image about?"
            },
            {
                "type": "input_image",
                "image_url": f"data:image/png;base64,{encoded_file}"
            }
            
        }
    ]
}
r = requests.post(url, headers=headers, json=payload)
print(json.dumps(r.json(), indent=2))


Supported MIME types for images

Extension(s) MIME type Base64 prefix
.png image/png data:image/png;base64,
.jpg, .jpeg image/jpeg data:image/jpeg;base64,
.gif image/gif data:image/gif;base64,
.webp image/webp data:image/webp;base64,

3.2 PDF input (Python example)

import base64, json, requests

token = "SAIA_APITOKEN"
url   = "$BASE_URL/responses"
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}

def encode_file(file_path):
    with open(file_path, 'rb') as file:
        return base64.b64encode(file.read()).decode('utf-8')

file_path = "/path/to/your/sample.pdf"
encoded_file = encode_file(file_path)

payload = {
    "model": "openai/o4-mini",
    "input":  
        {
            "role": "user",
            "content": [
            {
                "type": "input_text",
                "text": "What's this file about?"
            },
            {
                "type": "input_file",
                "filename": "sample.pdf",
                "file_data": f"data:application/pdf;base64,{encoded_file}"
            }
            
        }
    ]
}
r = requests.post(url, headers=headers, json=payload)
print(json.dumps(r.json(), indent=2))

Note: Only models that support both text and image inputs, such as gpt-4o, gpt-4.1, or o1, can accept PDF files as input.

Usage and Cost Calculation

The usage object includes token consumption and calculated costs for supported models.

For some providers and models, pricing is conditional and may vary depending on:

  • Prompt tokens
  • Completion tokens
  • Cached prompt tokens
  • Provider-specific pricing schemes

The platform automatically applies the corresponding pricing model based on the provider and model used.

Cost breakdown fields

Field Description
prompt_tokens Total input tokens processed by the model.
completion_tokens Tokens generated in the response.
cached_tokens Tokens reused from cache within prompt tokens, when supported by the provider.
prompt_cost Cost associated with prompt token consumption.
completion_cost Cost associated with generated tokens.
total_cost Final calculated request cost.
currency Currency used for cost reporting.

Conditional pricing behavior

Some models use differentiated pricing depending on token type.

Supported conditional pricing currently applies to selected models from:

  • Anthropic
  • Google Vertex AI
  • AWS Bedrock
  • OpenAI

For supported models, cached prompt tokens may be priced differently from standard prompt tokens.

The platform automatically handles these calculations and exposes the final breakdown through the usage object.

Supported models

Anthropic

  • claude-sonnet-4-20250514
  • claude-sonnet-4-5-20250929
  • claude-sonnet-4-6
  • claude-opus-4-6

Google Vertex AI

  • claude-sonnet-4-20250514
  • claude-sonnet-4-5
  • claude-sonnet-4-5-20250929
  • claude-sonnet-4-6
  • claude-opus-4-6
  • gemini-2.5-pro
  • gemini-3-pro-preview
  • gemini-3.1-pro-preview

AWS Bedrock

  • us.anthropic.claude-sonnet-4-5-20250929
  • eu.anthropic.claude-sonnet-4-5-20250929
  • us.anthropic.claude-sonnet-4-6
  • eu.anthropic.claude-sonnet-4-6
  • us.anthropic.claude-opus-4-6-v1
  • eu.anthropic.claude-opus-4-6-v1

OpenAI

  • gpt-5.4
  • gpt-5.4-pro

Request sample

{
  "model": "string",     // e.g., "openai/gpt-5.4"
  "input": "string",     // e.g., "Explain quantum computing in simple terms."
  "stream": false        // Disable streaming and return a complete response
}

Response

Response sample with comments

{
  "top_logprobs": integer,                       // Number of top log-probabilities requested per token (0 if none requested)
  "instructions": "string",                      // System or supplemental instructions applied; null if none
  "metadata": {},                                // Key/value metadata associated with this response (object of arbitrary fields)
  "max_tool_calls": integer,                     // Max allowed tool calls for this response; null if not constrained
  "presence_penalty": number,                    // Presence penalty applied to sampling (e.g., 0.0 if none)

  "reasoning": {                                 // Reasoning-related configuration and summaries
    "summary": "string",                         // Short reasoning summary, if provided; null if absent
    "context": "string",                         // Reasoning scope (e.g., "current_turn")
    "effort": "string"                           // Effort level (e.g., "none", "low", "medium", "high")
  },

  "usage": {                                     // Token and cost accounting
    "total_cost": number,                        // Total cost charged for this response in the specified currency
    "completion_tokens_details": {
      "reasoning_tokens": integer                // Number of completion tokens attributed to reasoning
    },
    "prompt_tokens_details": {
      "cached_tokens": integer                   // Number of prompt tokens served from cache
    },
    "total_tokens": integer,                     // Total tokens (prompt + completion)
    "currency": "string"                         // Billing currency (e.g., "USD")
  },

  "created_at": integer,                         // Unix timestamp (seconds) when the response was created
  "safety_identifier": "string",                 // Safety/moderation trace identifier; null if not applicable
  "error": {},                                   // Error object if the request failed; null on success
  "tools": [],                                   // Array of tool invocation records (empty if no tools used)

  "billing": {                                   // Billing attribution
    "payer": "string"                            // Who is billed (e.g., "developer")
  },

  "output":                                     // Ordered list of output message blocks produced by the model
    {
      "phase": "string",                         // Processing phase for this message (e.g., "final_answer")
      "role": "string",                          // Author role (e.g., "assistant")
      "id": "string",                            // Unique message identifier
      "type": "string",                          // Message type (e.g., "message")
      "content": [                               // Structured content segments of the message
        {
          "annotations": [,                     // Optional annotations aligned to text spans
          "text": "string",                      // Plain text generated by the model
          "type": "string",                      // Content type (e.g., "output_text")
          "logprobs": []                         // Optional per-token log-probability details
        }
      ],
      "status": "string"                         // Message status (e.g., "completed")
    }
  ],

  "top_p": number,                               // Nucleus sampling parameter used (e.g., 0.98)
  "previous_response_id": "string",              // ID of a prior response in a chain; null if none
  "frequency_penalty": number,                   // Frequency penalty applied to sampling (e.g., 0.0 if none)
  "temperature": number,                         // Sampling temperature used (e.g., 1.0)
  "tool_choice": "string",                       // Tool selection mode (e.g., "auto")
  "model": "string",                             // Model identifier actually used (e.g., "openai/gpt-5.4")
  "service_tier": "string",                      // Service tier or priority (e.g., "priority")
  "id": "string",                                // Unique response identifier

  "text": {                                      // Text rendering preferences for the response
    "format": {
      "type": "string"                           // Output format type (e.g., "text")
    },
    "verbosity": "string"                        // Output verbosity level (e.g., "medium")
  },

  "incomplete_details": {},                      // Details if response was truncated/incomplete; null if complete
  "truncation": "string",                        // Truncation mode (e.g., "disabled")
  "prompt_cache_key": "string",                  // Cache key used for prompt caching; null if not cached
  "store": boolean,                              // Whether the response is stored server-side
  "completed_at": integer,                       // Unix timestamp (seconds) when the response completed
  "parallel_tool_calls": boolean,                // Whether multiple tools could be invoked in parallel
  "background": boolean,                         // Whether the job ran in background mode
  "moderation": {},                              // Moderation result object; null if not available
  "user": "string",                              // End-user identifier for attribution; null if not provided
  "object": "string",                            // Object type (e.g., "response")
  "max_output_tokens": integer,                  // Cap on output tokens if set; null if default
  "status": "string",                            // Overall response status (e.g., "completed")
  "prompt_cache_retention": "string"             // Prompt cache retention policy (e.g., "in_memory")
}

cURL Sample

curl --request POST \
  --url $BASE_URL/responses \
  --header "authorization: Bearer $GEAI_APITOKEN" \
  --header "content-type: application/json" \
  --data '{
    "model": "openai/gpt-5.4",
    "input": "Explain quantum computing in simple terms.",
    "stream": false
  }'
Last update: 2026 | © Globant S.A. All rights reserved.