Skip to content

AI Module

Rajesh Gautam edited this page Jun 12, 2026 · 1 revision

AI Module (pcAI)

pcAI is a built-in AI module — no import needed. It is available from the first line of any Curl program.


Setup

Get a free API key at openrouter.ai/keys, then:

export CURL_AI_KEY=sk-or-your_key_here

That's all. Curl defaults to DeepSeek via OpenRouter.


Methods

pcAI.ask

Ask a question. Conversation history is kept across calls.

var{reply, pcAI.ask{"What is the capital of France?"}}\
pcType{var{reply}}\

pcAI.chat

Start an interactive chat loop in the terminal. Type exit to quit.

pcAI.chat{""}\

pcAI.context

Set a custom system prompt / persona. Resets conversation history.

pcAI.context{"You are a friendly pirate who speaks in rhymes."}\
var{reply, pcAI.ask{"What is 2 + 2?"}}\
pcType{var{reply}}\

pcAI.reset

Clear conversation history while keeping the current context.

pcAI.reset{""}\

pcAI.summarize

var{summary, pcAI.summarize{"paste a long paragraph here"}}\
pcType{var{summary}}\

pcAI.analyze

var{result, pcAI.analyze{"some data or text"}}\
pcType{var{result}}\

pcAI.sentiment

Returns one word: positive, negative, or neutral.

var{mood, pcAI.sentiment{"I love this!"}}\
pcType{var{mood}}\

pcAI.translate

var{translated, pcAI.translate{"Bonjour — translate to English"}}\
pcType{var{translated}}\

Configuration

Override the default model with environment variables:

Variable Default Description
CURL_AI_KEY (required) API key
CURL_AI_BASE_URL https://openrouter.ai/api/v1 API base URL
CURL_AI_MODEL deepseek/deepseek-chat-v3-0324 Model name

Use OpenAI

export CURL_AI_KEY=your_openai_key
export CURL_AI_BASE_URL=https://api.openai.com/v1
export CURL_AI_MODEL=gpt-4o-mini

Use Ollama (local, no key needed)

export CURL_AI_BASE_URL=http://localhost:11434/v1
export CURL_AI_MODEL=llama3.2
export CURL_AI_KEY=ollama

Use Curl-Bot (local via Ollama)

ollama pull hf.co/gautamritvik/Curl-Bot
export CURL_AI_BASE_URL=http://localhost:11434/v1
export CURL_AI_MODEL=hf.co/gautamritvik/Curl-Bot
export CURL_AI_KEY=ollama

Notes

  • Conversation history is kept automatically across pcAI.ask calls
  • History auto-compacts when it gets long (summarizes older messages)
  • Use pcAI.reset{""}\ to clear history
  • Use pcAI.context{...}\ to change the bot's personality

Clone this wiki locally