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 Globant Enterprise AI 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 --request POST \
  --url $BASE_URL/responses \
  -H "Authorization: Bearer $YOUR_SAIA_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
    "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 --request POST \
  --url $BASE_URL/responses \
  -H "Authorization: Bearer $YOUR_SAIA_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
   "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 --request POST \
  --url $BASE_URL/responses \
  -H "Authorization: Bearer $YOUR_SAIA_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
    "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 = "YOUR_SAIA_API_TOKEN"
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 = "YOUR_SAIA_API_TOKEN"
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.

Availability

Since May 2025 release.

Last update: March 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant