POST
/
talk-to-gpt
cURL
curl --request POST \
  --url https://nano-gpt.com/api/talk-to-gpt \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "prompt": "Please explain the concept of artificial intelligence.",
  "model": "chatgpt-4o-latest",
  "messages": [
    {
      "role": "user",
      "content": "Hi, I'\''m just testing!"
    }
  ]
}'
"<string>"

Overview

The Talk to GPT endpoint is our legacy text generation API that also supports web search capabilities through LinkUp integration. 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)
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": "chatgpt-4o-latest: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": "chatgpt-4o-latest: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'])

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

Authorizations

x-api-key
string
header
required

Body

application/json

Parameters for talking to GPT

model
string
default:chatgpt-4o-latest
required

The model to use for generation. Append ':online' for web search ($0.005/request) or ':online/linkup-deep' for deep web search ($0.05/request)

Examples:

"chatgpt-4o-latest"

"chatgpt-4o-latest:online"

"claude-3-5-sonnet-20241022:online/linkup-deep"

prompt
string
default:""

The text prompt to send to GPT (optional)

Example:

"Please explain the concept of artificial intelligence."

messages
object[]

Array of previous message objects for context (optional)

Response

Talk to GPT response

Text response followed by metadata in <NanoGPT> tags