> ## 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.

# First API Call

## Quick Start

Third-party applications can access various AI services provided by GeekAI through API interfaces. Currently, we offer AI model proxy, AI agent, file conversation, and OCR services (free), with more AI service interfaces to be gradually released in the future.

GeekAI API uses an OpenAI-compatible API format. By modifying configurations, you can use the OpenAI SDK to access GeekAI API, or use software that is compatible with OpenAI API (third-party application integration):

<div style={{ width: '100%', overflowX: 'auto' }}>
  <table style={{ width: '100%', borderCollapse: 'collapse', tableLayout: 'fixed' }}>
    <thead>
      <tr>
        <th style={{ border: '1px solid #ccc', padding: '10px', }}>Parameter</th>
        <th style={{ border: '1px solid #ccc', padding: '10px',width: '90%' }}>Value</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td style={{ border: '1px solid #ccc', padding: '8px' }}>Base URL</td>

        <td style={{ border: '1px solid #ccc', padding: '8px' }}>
          [https://geekai.dev/api/v1](https://geekai.dev/api/v1)
        </td>
      </tr>

      <tr>
        <td style={{ border: '1px solid #ccc', padding: '8px' }}>API KEY</td>

        <td style={{ border: '1px solid #ccc', padding: '8px' }}>
          [Get API KEY](https://geekai.dev/user/api_keys)
        </td>
      </tr>
    </tbody>
  </table>
</div>

<Note>
  Sometimes the Base URL cannot include the `/v1` suffix, especially in some third-party applications. In such cases, you need to adjust the Base URL according to the actual situation. If including the `/v1` suffix results in an error, try removing it.
</Note>

After creating and copying your API key, you can use the following sample code to access GeekAI API. The example demonstrates non-streaming output; you can set `stream` to `true` to use streaming output:

<CodeGroup>
  ```bash curl theme={null}
  curl https://geekai.dev/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {YOUR API KEY}" \
  -d '{
      "model": "gpt-4o-mini",
      "messages": [
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "Hello!"}
      ],
      "stream": false
  }'
  ```

  ```bash python theme={null}
  # First install OpenAI SDK: `pip3 install openai`

  from openai import OpenAI

  client = OpenAI(api_key="{YOUR API KEY}", base_url="https://geekai.dev/api/v1")

  response = client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[
          {"role": "system", "content": "You are a helpful assistant"},
          {"role": "user", "content": "Hello"},
      ],
      stream=False
  )

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

  ```bash nodejs theme={null}
  // First install OpenAI SDK: `npm install openai`

  import OpenAI from "openai";

  const openai = new OpenAI({
      baseURL: 'https://geekai.dev/api/v1',
      apiKey: '{YOUR API KEY}'
  });

  async function main() {
      const completion = await openai.chat.completions.create({
          messages: [{ role: "system", content: "You are a helpful assistant." }],
          model: "gpt-4o-mini",
      });

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

  main();
  ```
</CodeGroup>

The principle of streaming output is SSE (Server-Sent Events). When streaming output is enabled, the client-side code needs to be adapted to handle it. For example, in front-end code, you need to use EventSource to receive the streaming response from the server; otherwise, an error will occur.

## Analyze image inputs

If you want to analyze images, you can use the following example code:

<CodeGroup>
  ```bash curl theme={null}
  curl https://geekai.dev/api/v1/chat/completions   
    -H "Content-Type: application/json"
    -H "Authorization: Bearer $GEEKAI_API_KEY"   
    -d '{
      "model": "gpt-4o-mini",
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "What is in this image?"
            },
            {
              "type": "image_url",
              "image_url": {
                "url": "https://static.geekai.co/logo/geekai-logo-main-tr.png"
              }
            }
          ]
        }
      ]
    }'
  ```

  ```bash python theme={null}
  from openai import OpenAI

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

  response = client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "What is in this image?"},
                  {
                      "type": "image_url",
                      "image_url": {
                          "url": "https://static.geekai.co/logo/geekai-logo-main-tr.png",
                      },
                  },
              ],
          }
      ]
  )

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

  ```bash javascript theme={null}
  import OpenAI from "openai";

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

  const response = await openai.chat.completions.create({
      model: "gpt-4o-mini",
      messages: [
          {
              role: "user",
              content: [
                  { type: "text", text: "What is in this image?" },
                  {
                      type: "image_url",
                      image_url: {
                          url: "https://static.geekai.co/logo/geekai-logo-main-tr.png",
                      },
                  },
              ],
          },
      ],
  });

  console.log(response.choices[0].message.content);
  ```

  Only multimodal models that support image recognition also support image analysis. You can check all models that support image recognition in the [Model Plaza](https://geekai.dev/models).
</CodeGroup>

## Developer Group

If you encounter any issues during implementation, you can join our developer group for assistance. We will answer your questions promptly:

<img src="https://static.geekai.co/image/geekai_wechat_group.png" className="mt-2" alt="GeekAI Developer Group" />

In the group, you can receive the latest updates on GeekAI, technical sharing, product features, API usage, and other information.
