---
title: SparkLLM Chat
---

iFlyTek의 SparkLLM chat models API입니다. 자세한 내용은 [iFlyTek Open Platform](https://www.xfyun.cn/)을 참조하세요.

## 기본 사용법

```python
"""For basic init and call"""
from langchain_community.chat_models import ChatSparkLLM
from langchain.messages import HumanMessage

chat = ChatSparkLLM(
    spark_app_id="<app_id>", spark_api_key="<api_key>", spark_api_secret="<api_secret>"
)
message = HumanMessage(content="Hello")
chat([message])
AIMessage(content='Hello! How can I help you today?')
  • iFlyTek SparkLLM API Console에서 SparkLLM의 app_id, api_key, api_secret을 받으세요 (자세한 내용은 iFlyTek SparkLLM Intro 참조). 그런 다음 환경 변수 IFLYTEK_SPARK_APP_ID, IFLYTEK_SPARK_API_KEY, IFLYTEK_SPARK_API_SECRET을 설정하거나 위 예시처럼 ChatSparkLLM을 생성할 때 매개변수로 전달하세요.

Streaming을 사용하는 ChatSparkLLM

chat = ChatSparkLLM(
    spark_app_id="<app_id>",
    spark_api_key="<api_key>",
    spark_api_secret="<api_secret>",
    streaming=True,
)
for chunk in chat.stream("Hello!"):
    print(chunk.content, end="")
Hello! How can I help you today?

v2 버전

"""For basic init and call"""
from langchain_community.chat_models import ChatSparkLLM
from langchain.messages import HumanMessage

chat = ChatSparkLLM(
    spark_app_id="<app_id>",
    spark_api_key="<api_key>",
    spark_api_secret="<api_secret>",
    spark_api_url="wss://spark-api.xf-yun.com/v2.1/chat",
    spark_llm_domain="generalv2",
)
message = HumanMessage(content="Hello")
chat([message])

---

<Callout icon="pen-to-square" iconType="regular">
    [Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/chat/sparkllm.mdx)
</Callout>
<Tip icon="terminal" iconType="regular">
    [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for    real-time answers.
</Tip>
I