火山引擎字节跳动豆包AI对话接口

# pip install 'volcengine-python-sdk[ark]'

from volcenginesdkarkruntime import Ark


def chat_dance(desc):
    client = Ark(api_key='你的api_key')
    completion = client.chat.completions.create(
        model="ep-20240619083846-c4xff",
        messages=[
            {"role": "system", "content": "你是豆包,是由字节跳动开发的 AI 人工智能助手"},
            {"role": "user", "content": desc},
        ],
    )
    print(completion.choices[0].message.content)



if __name__ == '__main__':

    desc = '你好'
    chat_dance(desc)

需要安装库:

pip install 'volcengine-python-sdk[ark]'

获取api-key的地址:账号登录-火山引擎

获取模型id的地址,示例为Doubao-pro-32k:账号登录-火山引擎 

你可能感兴趣的:(Python,火山引擎,AI,火山引擎)