Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

ai-functions

Skill by polardb

Explains how to use the AI functions built into PolarDB-X, which let you call LLM, embedding, rerank and document parsing models directly from SQL. It is for developers who want AI-powered SQL queries or need to register and manage models.

  • Score 74
  • 1.7k stars
  • Apache-2.0
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install ai-functions

Built from the published package, never by AI.

git clone --depth 1 https://github.com/polardb/polardbx-sql /tmp/polardbx-sql && mkdir -p ~/.claude/skills && cp -r /tmp/polardbx-sql/polardbx-executor/src/main/resources/ai/skills/polardbx-ai-functions ~/.claude/skills/ai-functions

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install ai-functions in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This skill is a usage guide for the AI functions in PolarDB-X. It covers model management functions such as AI_REGISTER_MODEL, AI_UPDATE_MODEL, AI_DROP_MODEL, AI_LIST_MODELS and AI_DESCRIBE_MODEL. It also covers inference functions including AI_PROMPT, AI_EMBEDDING, AI_SIMILARITY, AI_CLASSIFY, AI_EXTRACT, AI_SUMMARIZE, AI_RANK, AI_TEXT2SQL, AI_PARSE_DOCUMENT and AI_VL_EMBEDDING.

The guide shows SQL examples for registering models with a provider, endpoint, model name and API key. It also shows how to call the functions on table data, such as classifying articles, extracting fields, or building a RAG pipeline. It is aimed at users who ask how to call AI models from SQL in PolarDB-X.

Written from the project's SKILL.md and checked against it.

What it can do

  • AI_REGISTER_MODELRegisters a model configuration with a provider, endpoint, model name and options.
  • AI_LIST_MODELSLists all registered models.
  • AI_PROMPTCalls an LLM to generate text from a prompt inside SQL.
  • AI_EMBEDDINGGenerates text embedding vectors that can be stored in a table.
  • AI_SIMILARITYComputes similarity between texts or vectors using cosine, euclidean or dot distance.
  • AI_CLASSIFYAssigns text to one of a list of categories.
  • AI_EXTRACTExtracts structured fields from text based on a JSON template.
  • AI_SUMMARIZEProduces a text summary with an optional length and style.
  • AI_RANKScores the relevance of documents to a query for reranking.
  • AI_TEXT2SQLGenerates SQL from a natural language request using the current schema.

What you need

  • PolarDB-X instance with AI functions
  • API key from a supported model provider such as dashscope or openai
  • AI_GATEWAY_KEY parameter set at instance level for the default built-in model

Try asking

  • Register a dashscope qwen-plus model in PolarDB-X with AI_REGISTER_MODEL
  • Classify each article in my articles table with AI_CLASSIFY
  • Write SQL that uses AI_SIMILARITY to find the most similar documents

Good to know

  • AI function calls go to external APIs and have network latency.
  • Not recommended for large batch queries, according to the guide.
  • Inference functions need a registered model with an API key first.
  • Supported model lists differ by provider.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: polardbx-executor/src/main/resources/ai/skills/polardbx-ai-functions/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Alternatives to ai-functions

All alternatives →
hugging-face-datasetssickn33
94

Creates, configures and manages datasets on the Hugging Face Hub, including SQL-based querying and transformation. Built for people who edit dataset content and metadata directly, alongside the HF MCP server.

AAA Skill 50k
db-repairgarrytan
94

Diagnoses and repairs gbrain's Postgres access when a command or MCP result shows a GBRAIN_DB_ACCESS marker, or when the operator reports the brain database is down. It runs the hardcoded gbrain db-repair ladder and verifies the result with a re-probe.

AAA Skill 34k
alloydb-basicsgoogle
94

Manages clusters, instances, and backups for AlloyDB for PostgreSQL. Built for creating, configuring, and administering AlloyDB databases, not general PostgreSQL or Cloud SQL instances.

AAA Skill 26k
clickhouse-logs-queriessupabase
94

Writes, reviews and migrates Supabase logs queries against the ClickHouse logs table served by the logs.all.otel endpoint. Built for developers who write Logs Explorer SQL or convert older BigQuery logs queries.

AAA Skill 116k
fix-slow-queriespaperclipai
94

Diagnoses and fixes slow Paperclip PostgreSQL queries using Cloud and Neon evidence, local benchmarks, regression tests, and a pull request with passing checks. Built for engineers working on Paperclip.

AAA Skill 119k
prisma-8prisma
94

Guides AI assistants through Prisma 8 projects built on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo. It covers data contracts, migrations, typed queries and runtime setup for developers on Prisma 8.

AAA Skill 48k

Compare with hugging-face-datasets, db-repair or alloydb-basics

ai-functions: common questions

Do I need an API key to use the AI functions?

Yes. The guide says models must be registered with an API key before the inference functions can be used. The default built-in model needs the AI_GATEWAY_KEY parameter set at instance level.

Can I use AI functions on large tables?

The guide says AI function calls call external APIs with network latency and are not recommended for large batch queries.

Which model providers are supported?

The examples use dashscope and openai as provider values. The guide notes that supported models differ by provider and refers to each platform's documentation.

How do I install ai-functions?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is ai-functions free?

The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.

Is ai-functions safe to use?

It scores 74 of 100. Grades: maintenance B, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to ai-functions?

Similar skills: hugging-face-datasets, db-repair, alloydb-basics, clickhouse-logs-queries.

ai-functions Install

Add to stack

Loading.