# Baidu Qianfan MCP

> Baidu Qianfan connects your AI agent directly to enterprise LLM services for Chinese language applications. This MCP manages chat completions, generates vector embeddings for RAG systems, creates images from text prompts, and lets you monitor model usage—all through one standard connection.

## Overview
- **Category:** industry-titans
- **Price:** Free
- **Tags:** ernie-bot, baidu-cloud, llm-api, embeddings, prompt-templates, chinese-llm

## Description

You can run complex workflows without leaving your agent interface. Think of it like a central control panel for high-performance AI models: trigger conversations with advanced chat completions using persistent context; generate the vector embeddings needed to power custom search indexes; or create detailed images just by typing a prompt.

The platform also lets you manage everything from model access and usage tracking to retrieving standardized prompt templates. If your work involves integrating multiple types of large language models into an application, this is what you need. Vinkius makes connecting these specialized services simple, letting your agent talk to Baidu's full suite of AI tools without needing complex API wrapper code. It means the power of enterprise-grade Chinese LLMs is available right where you’re working.

## Tools

### get_embeddings
Converts text into a numerical vector, which allows your agent to measure the semantic similarity between documents.

### list_train_jobs
Checks the status and history of any active or completed model training jobs.

### chat_completions
Sends a message and context history to a Baidu Qianfan model to get a natural language reply.

### list_datasets
Retrieves a list of all data sets you have uploaded and indexed within the platform.

### list_models
Shows which specific AI model services are available for use right now.

### text_to_image
Creates a unique image file based on a detailed text prompt you provide.

## Prompt Examples

**Prompt:** 
```
Chat with Ernie Bot 4.0 and ask 'Write a formal apology letter for a late shipment'.
```

**Response:** 
```
Connecting to Qianfan engine... Ernie 4.0 responded: 'Subject: Formal Apology... We sincerely regret the delay in your shipment #12345...' Would you like me to refine the tone?
```

**Prompt:** 
```
Generate embeddings for the text 'The quick brown fox jumps over the lazy dog'.
```

**Response:** 
```
Retrieving embeddings... I've generated a 384-dimensional vector for your input using Baidu's embedding-v1 model. The data is ready for your RAG search index.
```

**Prompt:** 
```
List all my prompt templates in Qianfan.
```

**Response:** 
```
Fetching templates... I found 3 templates: 1. Code-Review-Expert (ID: tp_1), 2. Creative-Writer (ID: tp_2), 3. SQL-Generator (ID: tp_3). Which one would you like to use?
```

## Capabilities

### Run Conversational AI
Start and continue conversations with powerful foundation models, maintaining context across multiple turns.

### Index Text for Search
Convert any block of text into mathematical vector embeddings so your agent can perform deep semantic searches against private datasets.

### Generate Visual Content
Create original images using advanced diffusion models, simply by providing a descriptive text prompt.

### Manage AI Prompts
Access and retrieve standardized prompt templates to ensure your model outputs are always consistent in tone and format.

### Audit Usage Metrics
Monitor token consumption and service status programmatically, giving you a clear picture of your operational costs.

## Use Cases

### Building a Customer Support Chatbot
The agent needs to answer questions based on hundreds of internal manuals. First, it uses `get_embeddings` on the manual text chunks and indexes them. Then, when a user asks a question, the agent runs a conversation using `chat_completions`, referencing those indexed documents for accurate answers.

### Creating Marketing Assets at Scale
A product manager needs 20 unique headers for an ad campaign. Instead of manually prompting an image generator, the agent loops through a list of concepts and executes `text_to_image` twenty times, collecting all assets in one go.

### Comparing Model Performance
A development team wants to know if the new 'Speed' model is better than the old 'Turbo' model for summarization. They use `list_models` to confirm both are active, then run parallel tests using `chat_completions` on the exact same data set.

### Auditing AI Costs
The finance team needs a report showing how much token usage was consumed last month. They programmatically check the model service status and consumption metrics to ensure billing is accurate before submitting the budget proposal.

## Benefits

- Control model access: Easily check which services are available using the `list_models` tool. This stops you from accidentally calling an endpoint that's deprecated or offline.
- Power RAG systems: Generate accurate vector embeddings for any text using `get_embeddings`, letting your agent search private knowledge bases, not just its training data.
- Consistent outputs: Manage and retrieve centralized prompt templates so all model calls—whether it’s writing code or generating a report—use the same high-quality structure.
- Multi-modal capability: Beyond text, you can trigger advanced image generation tasks using `text_to_image` to create visual assets directly from your agent's workflow.
- Deep operational visibility: Keep track of costs and usage by monitoring token consumption. This helps you budget and optimize your calls with the service status check.

## How It Works

The bottom line is: You connect once at Vinkius, and that gives you control over multiple enterprise AI services.

1. First, subscribe to this MCP and log into the Baidu Qianfan Console. You'll need an API Key and Secret Key.
2. Next, you enable the specific models you want to use—like a certain version of Ernie Bot or a specialized embedding model.
3. Finally, plug those credentials into your AI client via Vinkius. Your agent can then access and run all the available tools.

## Frequently Asked Questions

**How do I use the chat_completions tool with my proprietary data?**
You first run `get_embeddings` on your documents to convert them into vectors. Then, when you call `chat_completions`, the agent uses those vectors as context for the model so it answers based on your private data.

**Can I generate images using text_to_image within my workflow?**
Yes. You can trigger image generation tasks directly through this MCP, which is useful when you need to create visual content that matches the context of a conversation or article.

**What if I want to check what models are available for chat_completions?**
You simply use `list_models`. This tool shows all the specific AI services you have access to, letting you choose the best one for your current task.

**How do I know if a model is ready for production use?**
Use `list_train_jobs` to check the status of any model training. This confirms that the model has finished its job and is stable enough for real-world integration.

**When I call `get_embeddings`, what credentials do I need for my AI agent?**
You must provide a valid API Key and Secret Key. These are generated in the Baidu Qianfan Console. Your agent uses these keys to authenticate your requests, ensuring secure access to the embedding service.

**If I run `chat_completions`, what happens if my calls hit a rate limit?**
The API response will include an explicit error code detailing the rate violation. Your client should implement exponential backoff and retry logic to gracefully manage temporary service restrictions.

**How do I use `list_datasets` to verify my data sources before RAG?**
The tool lists available datasets, providing IDs and names. To actually ingest or query the content, you'll need a separate workflow step that passes those listed identifiers to your retrieval pipeline.

**How does `list_train_jobs` help me monitor custom model development?**
It fetches metadata about active and completed training runs. This lets you check the current status, review job IDs, and verify when a customized foundation model is ready for deployment.

**Which version of Ernie Bot should I use for chat?**
For high performance and reasoning, use `ernie-4.0-8k`. For faster response times and cost efficiency, `ernie-speed-128k` or `ernie-lite-8k` are excellent choices.

**Can I automatically generate embeddings for RAG?**
Yes! Use the `get_embeddings` tool with your text input. The agent will retrieve the vector representations from Baidu's embedding models, ready for indexing in your vector database.

**How do I use prompt templates from the console?**
Use the `list_prompt_templates` tool to find your configured templates. You can then retrieve specific details using `get_prompt_template` to maintain consistency across your AI workflows.