> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use in MindSearch

> Integrate AnyFast AI models with MindSearch — the open-source AI search engine.

## 1. Get an API Key

Open the [AnyFast console](https://www.anyfast.ai/) and sign up (or log in if you already have an account). After signing up, go to **API Keys**, create a new API Key, and copy it for later use.

## 2. Deploy MindSearch

Clone MindSearch and install dependencies (see the [MindSearch README](https://github.com/InternLM/MindSearch/blob/main/README.md)).

Edit `/path/to/MindSearch/mindsearch/models.py` and add the AnyFast API configuration:

```python theme={null}
anyfast_config = dict(
    type=GPTAPI,
    model_type='gpt-4o',
    key=os.environ.get('ANYFAST_API_KEY', 'YOUR ANYFAST API KEY'),
    openai_api_base='https://www.anyfast.ai/v1/chat/completions',
    meta_template=[
        dict(role='system', api_role='system'),
        dict(role='user', api_role='user'),
        dict(role='assistant', api_role='assistant'),
        dict(role='environment', api_role='system')
    ],
    top_p=0.8,
    top_k=1,
    temperature=0,
    max_new_tokens=8192,
    repetition_penalty=1.02,
    stop_words=['<|im_end|>']
)
```

Start the backend:

```bash theme={null}
# Set your AnyFast API Key
export ANYFAST_API_KEY=<your-api-key>

# Start MindSearch
python -m mindsearch.app --lang en --model_format anyfast_config --search_engine DuckDuckGoSearch
```

Start the frontend (Gradio example):

```bash theme={null}
python frontend/mindsearch_gradio.py
```

## 3. Deploy to HuggingFace Space

You can also deploy to HuggingFace Spaces:

* Create a new Space at [huggingface.co/new-space](https://huggingface.co/new-space) with **Gradio** template and **Blank** configuration.
* Go to **Settings** and add your AnyFast API Key as a secret.
* Upload the MindSearch directory, `requirements.txt`, and an `app.py` file.

For a complete example, refer to the [MindSearch + AnyFast HuggingFace Space](https://huggingface.co/spaces).

<script src="/feedback.js" />
