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

This documentation provides guidance on how to use OpenAI, Vertex AI Gemini, Anthropic and xAI LLMs with built-in web search capabilities through the Chat API (chat/completions).

Supported Models

Provider Model Environment Support
OpenAI openai/gpt-4o-search-preview Beta, Production
OpenAI openai/gpt-4o-mini-search-preview Beta, Production
Vertex AI vertex_ai/gemini-2.0-flash Beta, Production
Vertex AI vertex_ai/gemini-2.5-pro-exp-03-25 Beta, Production
Vertex AI vertex_ai/gemini-2.5-pro-preview-05-06 Beta, Production
Anthropic anthropic/claude-3-5-haiku-20241022 Beta, Production
Anthropic anthropic/claude-3-5-sonnet-20241022 Beta, Production
Anthropic anthropic/claude-3-7-sonnet-latest Beta, Production
Anthropic anthropic/claude-sonnet-4-20250514 Beta, Production
Anthropic anthropic/claude-opus-4-20250514 Beta, Production
xAI xai/grok-3 Beta, Production
xAI xai/grok-3-fast Beta, Production
xAI xai/grok-3-mini Beta, Production
xAI xai/grok-3-mini-fast Beta, Production
xAI xai/grok-3-mini-fast Beta, Production
xAI xai/grok-2-vision-1212 Beta, Production

Request Format

OpenAI Example Request

curl --request POST \
  --url $BASE_URL/chat/completions \
  --header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "openai/gpt-4o-search-preview",
    "messages": 
      {
        "role": "user",
        "content": "Who won the last presidential elections in USA?"
      }
    ,
    "stream": false,
    "max_completion_tokens": 1000
  }'

Note: For these two models, the OpenAI request body does not support the temperature parameter.

Expected Response

{
  "created": 1741876215,
  "usage": {
    "completion_tokens": 432,
    "prompt_tokens": 10,
    "total_cost": 0.004345,
    "total_tokens": 442,
    "currency": "USD",
    "completion_cost": 0.00432,
    "prompt_cost": 0.000025
  },
  "model": "gpt-4o-search-preview-2025-03-11",
  "choices": 
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Donald Trump won the 2024 United States presidential election, defeating Vice President Kamala Harris in a historic political comeback. ([time.com(https://time.com/7173338/donald-trump-wins-election-2024/?utm_source=openai))"
      }
    }
  ],
  "object": "chat.completion"
}

Gemini Example Request

curl --request POST \
  --url $BASE_URL/chat/completions \
  --header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "vertex_ai/gemini-2.0-flash",
    "messages": 
      {
        "role": "user",
        "content": "What happened in Bahia Blanca, Argentina during the past days?"
      }
    ,
    "tools": 
      {
        "googleSearch": {}
      }
    
  }'

As shown in the provided sample, it is required to enable the googleSearch tool.

Expected Response

{

  "created": 1741876381,
  "usage": {
    "completion_tokens": 417,
    "prompt_tokens": 12,
    "total_cost": 0.000252,
    "total_tokens": 429,
    "currency": "USD"
  },
  "model": "gemini-2.0-flash",
  "choices": 
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "In the past few days, specifically around March 7, 2025, Bahia Blanca, Argentina, experienced a devastating extreme rainfall event and severe flooding."
      }
    }
  ,
  "object": "chat.completion"
}

Anthropic Example Request

curl --request POST \
  --url $BASE_URL/chat/completions \
  --header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
        "model": "anthropic/claude-3-7-sonnet-latest",
        "max_tokens": 1024,
        "messages": 
            {
                "role": "user",
                "content": "How do I update a web app to TypeScript 5.5?"
            }
        ,
        "tools": {
            "type": "web_search_20250305",
            "name": "web_search",
            "max_uses": 5
        }
    }'

As shown in the provided sample, it is required to enable the web_search tool.

Expected Response

{
  "id": "chatcmpl-6a652f54-0475-4ab6-97ad-9a32cd119401",
  "created": 1747663281,
  "model": "anthropic/claude-3-7-sonnet-latest",
  "object": "chat.completion",
  "system_fingerprint": null,
  "choices": 
    {
      "finish_reason": "length",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'll help you understand how to update a web app to TypeScript 5.5...",
        "function_call": null,
        "tool_calls": null
      }
    }
  ,
  "usage": {
    "prompt_tokens": 45575,
    "completion_tokens": 1215,
    "total_tokens": 46790,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "prompt_cost": 0.136725,
    "completion_cost": 0.018225,
    "total_cost": 0.15495,
    "currency": "USD"
  }
}

xAI Example Request

curl --request POST \
  --url $BASE_URL/chat/completions \
  --header 'Authorization: Bearer $SAIA_PROJECT_APITOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "xai/grok-3",
  "messages": 
      {
        "role": "user",
        "content": "Provide me a digest of F1 news in the last 24 hours."
      }
    ,
    "search_parameters": {
      "mode": "on",
      "return_citations": true
    },
"stream": false,
"max_tokens": 2000
}'


Expected Response

{
    "id": "6575fbe...",
    "created": 1748872322,
    "model": "xai/grok-3",
    "object": "chat.completion",
    "system_fingerprint": "fp_14ded4f0c8",
    "choices": 
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "Here is a digest of Formula 1 news from the last 24 hours, based on the latest available information as of June 2, 2025...",
                "role": "assistant",
                "tool_calls": null,
                "function_call": null
            }
        }
    ,
    "usage": {
        "completion_tokens": 502,
        "prompt_tokens": 2481,
        "total_tokens": 2983,
        "completion_tokens_details": {
            "accepted_prediction_tokens": 0,
            "audio_tokens": 0,
            "reasoning_tokens": 0,
            "rejected_prediction_tokens": 0
        },
        "prompt_tokens_details": {
            "audio_tokens": 0,
            "cached_tokens": 2
        },
        "number_searches": 3
    },
    "service_tier": null,
    "citations": 
        "https://www.motorsport.com/f1/news/",
        "...",
        "https://x.com/sextappen/status/1764713159678468301"
    
}

See Also

Availability

Since April 2025 release.

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