<a id="ai-faq"></a>

# Frequently Asked Questions about AI with Confluent Cloud for Apache Flink

Get answers to common questions about using large language models (LLMs) and
machine learning (ML) with Confluent Cloud for Apache Flink®.

## What is AI with Confluent Cloud for Apache Flink?

AI with Confluent Cloud for Apache Flink enables you to integrate LLMs and ML models into your
streaming data workflows seamlessly.

## How do I get started using AI with Confluent Cloud for Apache Flink?

Get started by clicking **SQL Workspaces** in the Confluent Cloud Console. For more
information, see [Run an AI Model](ai-model-inference.md#flink-sql-ai-model).

## How do I register a remote AI model?

Use the [CREATE MODEL](../flink/reference/statements/create-model.md#flink-sql-create-model) statement to register an
AI model that’s hosted outside Confluent Cloud. For more information, see
[Create a Remote AI Model](ai-model-inference.md#flink-sql-ai-model-create-model).

## How do I provide tools to an AI model?

Use the [AI_TOOL_INVOKE](../flink/reference/functions/model-inference-functions.md#flink-sql-ai-tool-invoke-function) function to
provide Model Context Protocol (MCP) tools and user-defined functions (UDFs) to
an AI model. For more information, see
[Invoke an AI Model](../flink/reference/functions/model-inference-functions.md#flink-sql-ai-tool-invoke-function).

## How can I forecast and detect anomalies in my data?

Use the [ML_FORECAST](../flink/reference/functions/model-inference-functions.md#flink-sql-ml-forecast-function) and
[ML_DETECT_ANOMALIES](../flink/reference/functions/model-inference-functions.md#flink-sql-ml-anomaly-detect-function) functions to
forecast and detect anomalies in your data. For more information, see
[Built-in AI/ML Functions](builtin-functions/overview.md#ai-builtin-functions-overview).

## How can I evaluate the performance of an AI model?

Use the [ML_EVALUATE](../flink/reference/functions/model-inference-functions.md#flink-sql-ml-evaluate-function) function to evaluate
the performance of an AI model.

## How can I use an AI model to generate text?

Use the [AI_PREDICT](../flink/reference/functions/model-inference-functions.md#flink-sql-ml-predict-function) function with an AI
model to generate text.

## How can I use an AI model to classify data?

Use the [ML_PREDICT](../flink/reference/functions/model-inference-functions.md#flink-sql-ml-predict-function) function with an AI
model to classify data.

## How can I create vector embeddings for retrieval-augmented generation (RAG)?

Use the [AI_EMBEDDING](../flink/reference/functions/model-inference-functions.md#flink-sql-ai-embedding-function) function to create
vector embeddings for RAG. For more information, see
[Vector search with Pinecone](external-tables/vector-search.md#flink-sql-ai-model-vector-search-pinecone).

## How can I do vector searches over external tables?

Use the [VECTOR_SEARCH_AGG](../flink/reference/functions/search-functions.md#flink-sql-vector-search-function) function to
do vector searches over external tables.

## How can I do key and text searches over external tables?

Use the [KEY_SEARCH_AGG](../flink/reference/functions/search-functions.md#flink-sql-key-search-function) and
[TEXT_SEARCH_AGG](../flink/reference/functions/search-functions.md#flink-sql-text-search-function) functions to do key and
text searches over external tables.

## How can I use an AI model to generate text completions?

Use the [AI_COMPLETE](../flink/reference/functions/model-inference-functions.md#flink-sql-ai-complete-function) function with an
AI model to generate text completions.

## What are Streaming Agents?

Streaming Agents are AI-powered streaming applications that can reason over
streaming data and take actions through tool invocation. They process events,
make decisions, and interact with external systems in real-time.

Streaming Agents provide:
- Declarative agent definition
- Tool integration (function-based and MCP-based)
- Multi-agent workflows

For more information, see [Streaming Agents Overview](streaming-agents/overview.md#ai-streaming-agents-overview).

## How do I create a Streaming Agent?

Create a Streaming Agent using the `CREATE AGENT` statement:

```sql
CREATE AGENT customer_support_agent
USING MODEL my_model
USING PROMPT 'You are a helpful customer support agent'
USING TOOLS lookup_tool, support_api_tool
WITH (
  'max_iterations' = '5',
  'request_timeout' = '600'
);
```

You can also create tools using `CREATE TOOL`:

```sql
CREATE CONNECTION mcp_connection
WITH (
   'type' = 'mcp_server',
   'api-key' = '<api-key>',
   'endpoint' = 'https://mcp.example.com',
);

CREATE TOOL lookup_tool
USING CONNECTION mcp_connection
WITH (
  'type' = 'mcp',
  'description' = 'Lookup customer information'
);
```

For more information, see [CREATE AGENT Statement](../flink/reference/statements/create-agent.md#flink-sql-create-agent)
and [CREATE TOOL Statement](../flink/reference/statements/create-tool.md#flink-sql-create-tool).

## How do I execute a Streaming Agent?

Execute a Streaming Agent by using the `AI_RUN_AGENT` function:

```sql
SELECT *
FROM customer_context,
LATERAL TABLE(
  AI_RUN_AGENT('customer_support_agent', `prompt`, `request_id`));
```

The function processes streaming data through the agent and returns the
original data plus agent outputs.

For more information, see
[AI_RUN_AGENT Function](../flink/reference/functions/model-inference-functions.md#flink-sql-ai-run-agent-function).

## What types of tools can Streaming Agents use?

Streaming Agents support two types of tools:

**Function-based tools**: Wrap Flink UDFs and execute locally in the Confluent Cloud for Apache Flink
runtime. Best for high-frequency operations and low-latency requirements.

**MCP-based tools**: Connect to external services by using the Model Context
Protocol. Best for accessing external APIs and services.

For more information, see
[Create and Run Streaming Agents](streaming-agents/create-and-run-streaming-agents.md#streaming-agents-build-and-run).

<!-- How do I monitor Streaming Agents performance? -->
<!-- ********************************************** -->
<!-- Monitor Streaming Agents using: -->
<!-- - **Flink metrics**: Standard |af| monitoring and alerting -->
<!-- - **Agent-specific metrics**: Execution times, tool usage, error rates -->
<!-- - **Cost tracking**: Monitor model and tool usage costs -->
<!-- Query agent performance: -->
<!-- .. code:: sql -->
<!-- SELECT -->
<!-- agent_name, -->
<!-- AVG(execution_time_ms) as avg_time, -->
<!-- COUNT(*) as total_runs, -->
<!-- COUNT(CASE WHEN status = 'SUCCESS' THEN 1 END) as success_count -->
<!-- FROM agent_executions -->
<!-- WHERE timestamp >= CURRENT_TIMESTAMP - INTERVAL '1' HOUR -->
<!-- GROUP BY agent_name; -->

For more information, see [Agent Runtime Guide](streaming-agents/agent-runtime-guide.md#streaming-agents-runtime).

## Related content

- [Built-in AI/ML Functions](builtin-functions/overview.md#ai-builtin-functions-overview)
- [Create Embeddings](embeddings/overview.md#ai-embeddings-overview)
- [Search over External Tables](external-tables/overview.md#ai-external-tables-overview)
- [Streaming Agents](streaming-agents/overview.md#ai-streaming-agents-overview)
- [Vector search with Pinecone](external-tables/vector-search.md#flink-sql-ai-model-vector-search-pinecone)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
