SDK (Software Development Kit)
Also: 開發工具包 · software development kit · client library · 官方 SDK
A service's own pre-packaged toolkit: it wraps the details of calling its API into a few convenient functions so you do not assemble requests yourself.
When you will meet it
Tutorials offer two routes: install the official SDK, or curl the API yourself. Without knowing the difference you will lose a whole day hand-assembling requests that involve signing, streaming and retries — all of which the SDK already handles. Conversely, when an SDK version lags behind a new model feature, you need to know you can call the API directly instead.
An analogy
Calling the API directly is like building a computer from parts; using an SDK is buying the manufacturer's prebuilt machine. The prebuilt is easier and clearly supported, but you are stuck the moment you want a card the manufacturer never shipped.
Minimal example
同一件事的兩種寫法:
自己打 API(網址、標頭、JSON、錯誤、重試都得你自己處理)
POST https://api.example.com/v1/chat/completions
Header: Authorization: Bearer <你的 API key>
Body: {"model": "...", "messages": [{"role":"user","content":"你好"}]}
→ 然後自己解析回傳的那一大段 JSON
用官方 SDK(pip install 之後)
client = OpenAI() # key 自動從環境變數讀
resp = client.chat.completions.create(model="...", messages=[...])
print(resp.choices[0].message.content)Three things the SDK does for you: read the key from the environment, assemble the request in the correct shape, and turn the reply JSON into an object you can reach with dots. Two things it never does for you: decide what to ask the model, and check whether the answer is right.
What people get wrong
- Assuming an SDK and an API are two different systems with different capabilities. Underneath, the SDK calls the same API — it is only a wrapper. Whatever the API can do the SDK broadly can too, but brand-new features often have to wait for an SDK release.
- Assuming that because one vendor ships an SDK, another vendor cannot be used. Most model providers offer an 'OpenAI-compatible' API, so the same SDK can point somewhere else by changing base_url.