> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geekai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# URL Context

极客智坊支持了 Gemini 最近发布的一项实现性功能 —— URL Context，它可以让模型直接访问网页内容并进行分析。通过 URL Context，模型可以获取网页的文本内容、图片和其他媒体资源，从而更好地理解和回答与该网页相关的问题，只需要在 Prompt 中嵌入对应的 URL 即可。

在调用对话 API 时，可以通过将 `enable_url_context` 参数设置为 `true` 来开启该功能：

<CodeGroup>
  ```bash curl theme={null}
  curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
  --header 'Authorization: Bearer $GEEKAI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "model": "gemini-2.5-flash",
      "messages": [
          {
              "role": "user",
              "content": "通过分析网页内容介绍 URL Context 功能以及给出目前支持该特性的 Gemini 模型：https://ai.google.dev/gemini-api/docs/url-context"
          }
      ],
      "enable_url_context": true
  }'
  ```

  ```bash python theme={null}
  # 先安装 OpenAI SDK: `pip3 install openai`

  from openai import OpenAI

  client = OpenAI(api_key="$GEEKAI_API_KEY", base_url="https://geekai.co/api/v1")

  response = client.chat.completions.create(
      model="gemini-2.5-flash",
      messages=[
          {
              "role": "user", 
              "content": "通过分析网页内容介绍 URL Context 功能以及给出目前支持该特性的 Gemini 模型：https://ai.google.dev/gemini-api/docs/url-context"，
          },
      ],
      enable_url_context=True
  )

  print(response.choices[0].message.content)
  ```

  ```bash javascript theme={null}
  // 先安装 OpenAI SDK: `npm install openai`

  import OpenAI from "openai";

  const openai = new OpenAI({
      baseURL: 'https://geekai.co/api/v1',
      apiKey: '$GEEKAI_API_KEY'
  });

  async function main() {
      const completion = await openai.chat.completions.create({
          model: "gemini-2.5-flash",
          messages: [
            { role: "user", content: "通过分析网页内容介绍 URL Context 功能以及给出目前支持该特性的 Gemini 模型：https://ai.google.dev/gemini-api/docs/url-context" }],
          enable_url_context: true
      });

      console.log(completion.choices[0].message.content);
  }

  main();
  ```

  ```bash go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	requestBody := map[string]interface{}{
  		"model": "gemini-2.5-flash",
  		"messages": []interface{}{
              map[string]interface{}{
                  "role": "user", 
                  "content": "通过分析网页内容介绍 URL Context 功能以及给出目前支持该特性的 Gemini 模型：https://ai.google.dev/gemini-api/docs/url-context",
              },
          },
          "enable_url_context": true,
  	}
  	
  	jsonData, err := json.Marshal(requestBody)
  	if err != nil {
  		panic(err)
  	}

  	client := &http.Client{}
  	req, err := http.NewRequest("POST", "https://geekai.dev/api/v1/chat/completions", bytes.NewBuffer(jsonData))
  	if err != nil {
  		panic(err)
  	}

  	req.Header.Set("Authorization", "Bearer $GEEKAI_API_KEY")
  	req.Header.Set("Content-Type", "application/json")

  	resp, err := client.Do(req)
  	if err != nil {
  		panic(err)
  	}
  	defer resp.Body.Close()

  	body, err := io.ReadAll(resp.Body)
  	if err != nil {
  		panic(err)
  	}

  	fmt.Println(string(body))
  }
  ```
</CodeGroup>

作为实验性特性，目前该功能完全免费，不收取任何费用，不过仅极客智坊官方直连代理通道支持该功能，低价渠道暂不支持。

目前仅以下模型支持该实验特性，且每次请求最多可使用 20 个网址进行分析：

* `gemini-3.1-pro-preview`
* `gemini-3.1-pro-preview:fast-thinking`
* `gemini-3-flash-preview`
* `gemini-3-flash-preview:no-thinking`
* `gemini-2.5-pro`
* `gemini-2.5-pro:fast-thinking`
* `gemini-2.5-flash`
* `gemini-2.5-flash:no-thinking`
* `gemini-2.5-flash-lite`
* `gemini-2.5-flash-lite:no-thinking`
* `gemini-2.0-flash`

你还可以结合[联网搜索](https://docs.geekai.co/cn/docs/chat/web_search)同时启用搜索+URL Context 对对话结果进行增强。

更多对话 API 参数细节，请参考[对话 API 手册](https://docs.geekai.co/cn/api/chat/completions)。
