You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
API reference: Data plane
OpenAI SDK compatibility note
Copy page
Download PDF
OpenAI SDK compatibility note

To facilitate integration and usage, the operator API of LAS is designed to be as compatible as possible with the OpenAI API. By modifying a few configurations such as base url, model, and api_key, you can easily integrate ModelArk model services into your existing system.

tip

Community third-party SDKs are not maintained by the Volcano Engine team. This document is for reference only.

Prerequisites

Before calling the operator, you need to generate an API Key for operator invocation. It is recommended to configure the API Key as an environment variable for more secure operator calls. For details, see API key management.

OpenAI SDK
  • Python version: 3.7 or above.
  • OpenAI SDK: version 1.0 or above. Installation command:
pip install --upgrade "openai>=1.0"

Quick start example

from openai import OpenAI
import os

client = OpenAI(   
    # The base URL for model invocation
    base_url="https://operator.las.ap-southeast-1.volces.com/api/v1",   
    # Replace with your API Key
    api_key=os.environ.get("ARK_API_KEY"), 
)

completion = client.chat.completions.create(
    # Replace with Model ID
    model="doubao-seed-1-6-251015", 
    messages = [
        {"role": "user", "content": "Hello"},
    ],
)
print(completion.choices[0].message.content)

Set additional fields

To pass fields not supported by the OpenAI SDK, use the extra_body dictionary, such as the thinking field to toggle deep thinking for the model.

from openai import OpenAI
import os

client = OpenAI(   
    # The base URL for model invocation
    base_url="https://operator.las.ap-southeast-1.volces.com/api/v1",  
    # Replace with your API Key
    api_key=os.environ.get("ARK_API_KEY"), 
)

completion = client.chat.completions.create(
    # Replace with Model ID
    model="doubao-seed-1-6-251015", 
    messages = [
        {"role": "user", "content": "Hello"},
    ],
    extra_body={
         "thinking": {
             "type": "disabled", # Deep thinking capability not enabled
             # "type": "enabled", # Deep thinking capability enabled
         }
     }
)
print(completion.choices[0].message.content)

Set custom header

This can be used to pass extra information, such as configuring an ID to link logs or enabling data encryption capabilities.

from openai import OpenAI
import os

client = OpenAI(   
    # The base URL for model invocation
    base_url="https://operator.las.ap-southeast-1.volces.com/api/v1",  
    # Replace with your API Key
    api_key=os.environ.get("ARK_API_KEY"), 
)

completion = client.chat.completions.create(
    # Replace with Model ID
    model="doubao-seed-1-6-251015", 
    messages = [
        {"role": "user", "content": "Hello"},
    ],
    # Custom request id
    extra_headers={"X-Client-Request-Id": "202406251728190000B7EA7A9648AC08D9"}
)
print(completion.choices[0].message.content)

LangChain OpenAI SDK

Install LangChain OpenAI SDK:

pip install langchain-openai

Sample code

from langchain_openai import ChatOpenAI
from langchain_core.prompts import PromptTemplate
import os

llm = ChatOpenAI(
    # Replace with your API Key
    openai_api_key=os.environ.get("ARK_API_KEY"), 
    # The base URL for model invocation
    openai_api_base="https://operator.las.ap-southeast-1.volces.com/api/v1",   
    # Replace with Model ID
    model="doubao-seed-1-6-251015", 
)

template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate.from_template(template)

question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"

llm_chain = prompt | llm

print(llm_chain.invoke(question))
Last updated: 2026.05.24 15:27:26