Skip to main content
The platform supports accessing Gemini models using both the OpenAI chat/completions protocol and the native Gemini protocol. All examples below use non-streaming mode. To use streaming mode, change the Path to /gemini/v1/models/:streamGenerateContent.

Quick Start

curl https://api.highwayapi.ai/openai/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-d '{
    "model": "gemini-2.5-flash",
    "messages": [{
        "role": "user", "content": "What is the capital of France?"
    }],
    "reasoning_effort": "low"
  }'

OpenAI Protocol Thinking Control

The platform converts the reasoning_effort parameter in OpenAI chat/completions requests into Gemini thinking parameters.
reasoning_effortthinking
”disable”, “none""budget_tokens”: 0
”low""budget_tokens”: 1024
”medium""budget_tokens”: 2048
”high""budget_tokens”: 4096
⚠️ The non-standard OpenAI values disable/none can be used to turn off the thinking process.

Default Settings by Model

ModelDefault setting (when reasoning_effort is not set)
2.5 ProDynamic thinking: the model decides when to think and how much to think
2.5 FlashDynamic thinking: the model decides when to think and how much to think
2.5 Flash LiteThinking is disabled
⚠️ Thinking cannot be disabled for Gemini 2.5 Pro. reasoning_effort: none will be converted to the minimum thinkingBudget of 128. ⚠️ thinkingBudget is supported only in Gemini 2.5 Flash, 2.5 Pro, and 2.5 Flash-Lite. Depending on the prompt, the model may exceed or fall below the token budget.

Server-side Tool Use

With Google Search, Gemini models can be grounded in real-time web content and support all available languages. This allows Gemini to provide more accurate answers and cite verifiable sources beyond the knowledge cutoff date.
curl https://api.highwayapi.ai/openai/chat/completions \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-H "Content-Type: application/json" -d @- <<EOF
{
  "model": "gemini-2.5-flash-lite",
  "messages": [
    {
      "role": "user",
      "content": "List today's trending news in China"
    }
  ],
  "tools": [
    {
      "function": {"name": "google_search"}
    }
  ]
}
EOF
Example results are shown below. In the OpenAI protocol, grounding information can be obtained from the non-standard field gemini_grounding_metadata.
{
  "id": "dcc7eab10b5adeb9e8648d134e815409",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here are some of today's top news in China: ..."
      },
      "finish_reason": "stop"
    }
  ],
  "gemini_grounding_metadata": {  # 👈 GEMINI GROUNDING
    "webSearchQueries": [
      "top news in China today"
    ],
    ...
    "groundingChunks": [
      ...
    ]
  }
}

Code Execution

Gemini provides a code execution tool that allows the model to generate and run Python code. The model can then iteratively learn from the code execution results until it produces the final output.
curl https://api.highwayapi.ai/openai/chat/completions \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-H "Content-Type: application/json" -d @- <<EOF
{
  "model": "gemini-2.5-flash",
  "messages": [
    {
      "role": "user",
      "content": "What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50."
    }
  ],
  "tools": [
      {
           "function":  {"name": "code_execution"}
      }
  ],
  "reasoning_effort": "low"
}
EOF
Example results are shown below. For the OpenAI protocol, the code and code execution results will appear in content. For the Gemini protocol, the code is in the executableCode field, the execution result is in the codeExecutionResult field, and the summary is in the text field.
Okay, I can help you with that. I will write a Python script to find the
first 50 prime numbers and then calculate their sum.

Here's the plan:

1.  Create a function to check if a number is prime.
2.  Create a function to generate the first `n` prime numbers.
3.  Call the generation function for the first 50 primes.
4.  Sum the resulting list of primes.

Here is the code to perform this calculation:

```PYTHON
def is_prime(num):
    """Checks if a number is prime."""
    if num <= 1:
        return False
    if num <= 3:
        return True
    if num % 2 == 0 or num % 3 == 0:
        return False
    i = 5
    while i * i <= num:
        if num % i == 0 or num % (i + 2) == 0:
            return False
        i += 6
    return True

def get_first_n_primes(n):
    """Generates a list of the first n prime numbers."""
    primes = []
    num = 2
    while len(primes) < n:
        if is_prime(num):
            primes.append(num)
        num += 1
    return primes

# Get the first 50 prime numbers
first_50_primes = get_first_n_primes(50)


# Calculate the sum of these prime numbers

sum_of_primes = sum(first_50_primes)


print(f"The first 50 prime numbers are: {first_50_primes}")

print(f"The sum of the first 50 prime numbers is: {sum_of_primes}")
```

The first 50 prime numbers are: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
193, 197, 199, 211, 223, 227, 229]

The sum of the first 50 prime numbers is: 5117

URL context

With the URL context tool, you can provide additional context to the model in the form of URLs. By adding URLs to the request, the model will access the content of those web pages to inform and improve its response quality.
curl https://api.highwayapi.ai/openai/chat/completions \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-H "Content-Type: application/json" -d @- <<EOF
{
  "model": "gemini-2.5-flash-lite",
  "messages": [
    {
      "role": "user",
      "content": "Who is this recipe suitable for? https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592"
    }
  ],
  "tools": [
    {
      "function": {"name": "url_context"}
    }
  ]
}
EOF
An example response is shown below.
{
  "id": "82f10046aebe6697ed9d33a9fa398de4",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This recipe is about how to make Ina Garten's Perfect Roast Chicken.\n\n**Key information:**\n* **Recipe source:** Ina Garten, adapted from the Barefoot Contessa Cookbook.\n* **Prep time:** 20 minutes\n* **Cook time:** 1 hour 30 minutes\n* **Total time:** 2 hours 10 minutes\n* **Yield:** 8 servings\n* **Difficulty:** Intermediate\n\n**Ingredients:**\n* One 5- to 6-pound roasting chicken\n* Kosher salt\n* Freshly ground black pepper\n* A large bunch of fresh thyme, plus 20 sprigs\n* One lemon, halved\n* One head of garlic, cut in half crosswise\n* 2 tablespoons (1/4 stick) butter, melted\n* 1 large yellow onion, thickly sliced\n* 4 carrots, cut into 2-inch chunks\n* 1 bulb of fennel, tops removed, cut into wedges\n* Olive oil\n\n**Instructions:**\n1. Preheat the oven to 425°F (about 220°C).\n2. Remove the chicken giblets, then rinse the chicken inside and out. Remove any excess fat and leftover pin feathers, and pat the outside dry.\n3. Liberally salt and pepper the inside of the chicken. Stuff the cavity with the bunch of thyme, half a lemon, and all the garlic.\n4. Brush the outside of the chicken with the melted butter, then sprinkle again with salt and pepper.\n5. Tie the legs together with kitchen string and tuck the wing tips under the body of the chicken.\n6. Place the onions, carrots, and fennel in a roasting pan. Toss with salt, pepper, 20 sprigs of thyme, and olive oil. Spread the vegetables on the bottom of the roasting pan, then place the chicken on top.\n7. Roast the chicken for 1.5 hours, or until the juices run clear when you cut between a leg and thigh.\n8. Transfer the roasted chicken and vegetables to a platter, cover with aluminum foil, and let rest for about 20 minutes.\n9. Slice the chicken and serve it with the vegetables.\n\n**Cooking tips and user feedback:**\n* The recipe mentions that if the vegetables begin to brown on the bottom, you can add a cup of chicken stock to help keep them moist.\n* Some users recommend using a smaller roasting pan to avoid burning the vegetables.\n* Some users replaced the fennel with potatoes.\n* Many users said the chicken was very tender, juicy, flavorful, and easy to cook."
      },
      "finish_reason": "stop"
    }
  ],
  "gemini_grounding_metadata": {
    "groundingChunks": [
      {
        "web": {
          "uri": "https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592",
          "title": "Perfect Roast Chicken Recipe | Ina Garten | Food Network"
        }
      }
    ],
    "groundingSupports": [....]
  }
}