> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prismgateway.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI SDKs

> ใช้ Prism ผ่าน OpenAI JavaScript และ Python clients

# OpenAI SDKs

ตั้ง base URL ของ OpenAI SDK มาที่ Prism แล้วใช้ Prism API key

ตั้ง `PRISM_MODEL` เป็น chat model ก่อนรันตัวอย่าง โดย
[คู่มือเริ่มต้น](/th/quickstart) จะหา model ที่อยู่ทั้งใน trial allowlist และ
catalog ที่ API key มองเห็น แล้ว export model ที่ key เรียกได้ สำหรับ paid key หรือ
organization key ให้ใช้ chat model ที่อนุมัติสำหรับ key นั้น อย่าเลือกตามตำแหน่งจาก
`/v1/models` เพราะ catalog รวม chat, embedding, image และ video models

<CodeGroup>
  ```typescript JavaScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.PRISM_API_KEY,
    baseURL: "https://api.prismgateway.io/v1",
  });

  const model = process.env.PRISM_MODEL;
  if (!model) throw new Error("ตั้ง PRISM_MODEL เป็น chat model ที่ได้รับอนุมัติ");

  const response = await client.chat.completions.create({
    model,
    messages: [{ role: "user", content: "อธิบาย API นี้ในหนึ่งประโยค" }],
  });

  console.log(response.choices[0]?.message.content);
  ```

  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["PRISM_API_KEY"],
      base_url="https://api.prismgateway.io/v1",
  )

  model = os.environ["PRISM_MODEL"]

  response = client.chat.completions.create(
      model=model,
      messages=[{"role": "user", "content": "อธิบาย API นี้ในหนึ่งประโยค"}],
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

Chat, embeddings และ model list ใช้ OpenAI-compatible shape ส่วน video เป็น
async job API ของ Prism ดูตัวอย่างที่ [รูปภาพและวิดีโอ](/th/media)

[English version](/sdks)
