Metadata-Version: 2.4
Name: llama-index-llms-iflytek
Version: 0.1.0
Summary: llama-index llms iflytek spark integration
Author-email: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Requires-Python: <4.0,>=3.10
Requires-Dist: llama-index-core<0.15,>=0.13.0
Requires-Dist: llama-index-llms-openai-like>=0.3.4
Requires-Dist: openai>=1.0.0
Description-Content-Type: text/markdown

# LlamaIndex Llms Integration: iFlytek Spark

iFlytek Spark exposes an OpenAI-compatible chat-completions API, so this integration builds on `OpenAILike`.

## Installation

```bash
pip install llama-index-llms-iflytek
```

## Usage

Get an API password from the [iFlytek open platform console](https://console.xfyun.cn/) and pass it as `api_key` (or set the `IFLYTEK_API_KEY` environment variable). Pick a model such as `generalv3.5`, `4.0Ultra` or `lite`.

```python
from llama_index.llms.iflytek import IFlytek

llm = IFlytek(model="4.0Ultra", api_key="your-api-password")

response = llm.complete("用一句话介绍你自己")
print(response)
```

Chat and streaming work the same way as any other `OpenAILike` model:

```python
from llama_index.core.llms import ChatMessage

messages = [ChatMessage(role="user", content="Hello")]
for chunk in llm.stream_chat(messages):
    print(chunk.delta, end="")
```

The default API base is `https://spark-api-open.xf-yun.com/v1`; override it with the `IFLYTEK_API_BASE` environment variable or the `api_base` argument if needed.
