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

# Talk to GPT (Legacy)

> Legacy endpoint for chat interactions with the GPT model

## Overview

The Talk to GPT endpoint is our legacy text generation API that also supports web search capabilities through LinkUp integration.

The legacy endpoint supports the same model suffix parser for web search and provider routing as Chat Completions, but new integrations should use `/api/v1/chat/completions`. See [Model Suffixes](/api-reference/miscellaneous/model-suffixes).

The body `provider` field accepts either the existing provider ID string or a structured routing object with fields such as `order`, `only`, `ignore`, `sort`, `max_price`, `allow_fallbacks`, and `require_parameters`. See [Provider Selection > Provider Routing Object](/api-reference/miscellaneous/provider-selection#provider-routing-object).

## Web Search

Enable web search by appending suffixes to the model name:

* **`:online`** - Standard web search (\$0.006 per request)
* **`:online/linkup-deep`** - Deep web search (\$0.06 per request)

Provider routing suffixes such as `:fast` / `:speed`, `:cheap` / `:price` / `:floor`, `:throughput`, `:latency`, `:tools`, and `:caching` / `:cache` / `:cached` are also accepted for eligible models.

If you need direct control over search query, output mode (`searchResults` / `sourcedAnswer` / `structured`), or date/domain filters, use [Direct Web Search API (`POST /api/web`)](/api-reference/endpoint/web-search).

### Example with Web Search

<CodeGroup>
  ```python Python theme={null}
  import requests
  import json

  BASE_URL = "https://nano-gpt.com/api"
  API_KEY = "YOUR_API_KEY"

  headers = {
      "x-api-key": API_KEY,
      "Content-Type": "application/json"
  }

  # Standard web search
  data = {
      "prompt": "What are the latest AI breakthroughs this month?",
      "model": "openai/gpt-5.2:online",
      "messages": []
  }

  response = requests.post(
      f"{BASE_URL}/talk-to-gpt",
      headers=headers,
      json=data
  )

  # Deep web search for comprehensive research
  data_deep = {
      "prompt": "Provide a detailed analysis of recent quantum computing advances",
      "model": "openai/gpt-5.2:online/linkup-deep",
      "messages": []
  }

  response_deep = requests.post(
      f"{BASE_URL}/talk-to-gpt",
      headers=headers,
      json=data_deep
  )

  # Parse response
  if response.status_code == 200:
      parts = response.text.split('<NanoGPT>')
      text_response = parts[0].strip()
      nano_info = json.loads(parts[1].split('</NanoGPT>')[0])
      
      print("Response:", text_response)
      print("Cost:", nano_info['cost'])
  ```

  ```javascript JavaScript theme={null}
  const BASE_URL = "https://nano-gpt.com/api";
  const API_KEY = "YOUR_API_KEY";

  // Standard web search
  const response = await fetch(`${BASE_URL}/talk-to-gpt`, {
      method: 'POST',
      headers: {
          'x-api-key': API_KEY,
          'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          prompt: 'What are the latest AI breakthroughs this month?',
          model: 'openai/gpt-5.2:online',
          messages: []
      })
  });

  // Deep web search
  const deepResponse = await fetch(`${BASE_URL}/talk-to-gpt`, {
      method: 'POST',
      headers: {
          'x-api-key': API_KEY,
          'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          prompt: 'Provide a detailed analysis of recent quantum computing advances',
          model: 'openai/gpt-5.2:online/linkup-deep',
          messages: []
      })
  });
  ```

  ```bash cURL theme={null}
  # Standard web search
  curl -X POST https://nano-gpt.com/api/talk-to-gpt \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "What are the latest AI breakthroughs this month?",
      "model": "openai/gpt-5.2:online",
      "messages": []
    }'

  # Deep web search
  curl -X POST https://nano-gpt.com/api/talk-to-gpt \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Provide a detailed analysis of recent quantum computing advances",
      "model": "openai/gpt-5.2:online/linkup-deep",
      "messages": []
    }'
  ```
</CodeGroup>

## Important Notes

* Web search works with all models - simply append the suffix
* Increases input token count which affects total cost
* Provides access to real-time information
* For new projects, consider using the OpenAI-compatible `/v1/chat/completions` endpoint instead


## OpenAPI

````yaml POST /talk-to-gpt
openapi: 3.1.0
info:
  title: NanoGPT API
  description: >-
    API documentation for the NanoGPT language, image, video, speech-to-text,
    and text-to-speech generation services
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://nano-gpt.com/api
    description: NanoGPT API Server
security: []
paths:
  /talk-to-gpt:
    post:
      description: Legacy endpoint for chat interactions with the GPT model
      requestBody:
        description: Parameters for talking to GPT
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TalkToGptRequest'
        required: true
      responses:
        '200':
          description: Talk to GPT response
          content:
            text/plain:
              schema:
                type: string
                description: Text response followed by metadata in <NanoGPT> tags
        '400':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKeyAuth: []
components:
  schemas:
    TalkToGptRequest:
      type: object
      required:
        - model
      properties:
        prompt:
          type: string
          description: The text prompt to send to GPT (optional)
          default: ''
          example: Please explain the concept of artificial intelligence.
        model:
          type: string
          description: >-
            The model to use for generation. The legacy endpoint supports the
            same model suffix parser for web search and provider routing,
            including ':caching', ':cache', and ':cached', as Chat Completions.
          default: minimax/minimax-m2.7
          examples:
            - minimax/minimax-m2.7
            - zai-org/glm-5:fast
            - zai-org/glm-5:cheap
            - openai/gpt-5.2:online/exa-instant
        provider:
          description: >-
            Optional provider override or structured provider routing controls
            for provider-selection-capable models. A string explicitly selects
            one provider. An object can set soft order, hard pins, exclusions,
            sort preference, price caps, fallback behavior, and
            parameter-capability requirements.
          oneOf:
            - type: string
              description: Provider ID or accepted provider display name/alias.
            - $ref: '#/components/schemas/ProviderRoutingObject'
        messages:
          type: array
          description: Array of previous message objects for context (optional)
          default:
            - role: user
              content: Hi, I'm just testing!
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                description: The role of the message author
                enum:
                  - user
                  - assistant
              content:
                type: string
                description: The content of the message
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    ProviderRoutingObject:
      type: object
      description: >-
        Structured per-request provider routing controls. Per-request controls
        take precedence over saved provider preferences and are not merged with
        them.
      properties:
        order:
          type: array
          description: >-
            Soft provider preference order. NanoGPT tries these providers first
            when possible, but this does not hard-pin routing to only these
            providers. Unknown providers are ignored.
          items:
            type: string
        only:
          type: array
          description: >-
            Hard provider pin. NanoGPT restricts routing to these providers and
            fails instead of silently routing elsewhere. Unknown providers
            return a structured 400 error with code provider_unknown_provider.
          items:
            type: string
        ignore:
          type: array
          description: Providers to exclude from routing. Unknown providers are ignored.
          items:
            type: string
        sort:
          type: string
          description: >-
            Routing preference. speed, throughput, latency, and price actively
            request that strategy. auto, none, and default are accepted to
            suppress stored/default routing preferences without requesting a
            provider sort.
          enum:
            - speed
            - throughput
            - latency
            - price
            - auto
            - none
            - default
        quantizations:
          type: array
          description: >-
            Hard allowlist of model weight quantization levels. Providers
            without matching known quantization metadata are excluded unless
            unknown is included explicitly.
          minItems: 1
          items:
            type: string
            enum:
              - int4
              - fp4
              - fp6
              - int8
              - fp8
              - fp16
              - bf16
              - fp32
              - unknown
        min_quantization:
          type: string
          description: >-
            Minimum model weight quantization precision floor. Quantizations are
            ordered by bit width; integer and floating-point formats with the
            same bit width are treated as equivalent. unknown is not valid
            because it cannot be compared to a precision floor.
          enum:
            - int4
            - fp4
            - fp6
            - int8
            - fp8
            - fp16
            - bf16
            - fp32
        max_price:
          type: object
          description: >-
            Optional provider price caps in USD per 1 million tokens. Pricing
            checks are best-effort when provider pricing is unknown.
          properties:
            prompt:
              type: number
              description: Maximum prompt/input price in USD per 1 million tokens.
              minimum: 0
            completion:
              type: number
              description: Maximum completion/output price in USD per 1 million tokens.
              minimum: 0
        allow_fallbacks:
          type: boolean
          description: When false, disables cross-provider fallback for this request.
        require_parameters:
          type: boolean
          description: >-
            When true, requires the selected provider to support the requested
            parameters on routes that support parameter-level capability checks.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````