> For the complete documentation index, see [llms.txt](https://getsquish.gitbook.io/squish/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://getsquish.gitbook.io/squish/th/getting-started/quickstart-api.md).

# เริ่มต้นเร็ว: Hosted API

**ให้ AI เข้าถึงวิดีโอแบบสุ่มได้** Hosted API คือเส้นทางระยะไกลเข้าสู่เอนจินเดียวกับ CLI และเซิร์ฟเวอร์ MCP: `POST` อัปโหลดวิดีโอ แล้วรับไฟล์ JPG แบบ contact sheet ที่มีเวลาแปะกำกับ พร้อมข้อมูลเมตาแบบ JSON ที่มีรหัสเวลา (timecode) ของทุกช่อง ใช้เมื่อเวิร์กโฟลว์ไม่สามารถรันเครื่องมือในเครื่องได้ — เช่น CI, serverless, เอเจนต์ที่โฮสต์ไว้ หรือเครื่องใด ๆ ที่ไม่มี ffmpeg

{% hint style="info" %}
**เส้นทางนี้เป็นการอัปโหลดโดยตั้งใจ — ไปยังบริการประมวลผล ไม่ใช่บริการจัดเก็บ** วิดีโอที่อัปโหลดจะถูกลบทันทีเมื่อจบงาน ไม่ว่างานจะสำเร็จหรือล้มเหลว; จะไม่ถูกเก็บไว้และไม่ถูกนำไปใช้ฝึกโมเดลเลย แผ่นผลลัพธ์จะถูกเก็บเป็นแคชชั่วคราวที่ URL แบบความสามารถ (ประมาณ 24 ชั่วโมง) แล้วหมดอายุอัตโนมัติ — ดาวน์โหลดไว้หากต้องการเก็บต่อ ต้องการการรับประกันที่เข้มงวดกว่านี้ไหม? ให้รัน Squish ในเครื่อง: the [CLI](/squish/th/getting-started/quickstart-cli.md) และ [MCP server](/squish/th/getting-started/quickstart-mcp.md) จะไม่อัปโหลดวิดีโอของคุณเลย
{% endhint %}

## รับคีย์

1. เปิด [getsquish.app/api-keys](https://getsquish.app/api-keys) แล้วลงชื่อเข้าใช้ด้วยรหัสที่ส่งทางอีเมล
2. ซื้อแพ็กเครดิต ($3 = 30 · $9 = 120 · $29 = 500 เครดิต) — หรือข้ามขั้นตอนนี้ไปได้: บัญชีที่ไม่เคยซื้ออะไรเลยจะได้รับโควต้าฟรีรายวันโดยอัตโนมัติในการขอครั้งแรก
3. สร้างคีย์แล้วคัดลอกไว้ **ครั้งเดียว**. คีย์จะมีลักษณะเช่น `sq_live_` + อักขระฐานสิบหก 40 ตัว; ระบบเก็บไว้แค่แฮช ดังนั้นถ้าคีย์หายจะกู้คืนไม่ได้ ทำได้แค่สร้างใหม่แทน

## คำขอแรก

เอ็นด์พอยต์: `POST https://api.getsquish.app/v1/squish`. ยืนยันตัวตนด้วย `Authorization: Bearer <key>`; ส่ง `multipart/form-data` โดยมีฟิลด์ไฟล์เพียงหนึ่งช่องที่มีชื่อว่า **`video`**:

```bash
curl -s -X POST https://api.getsquish.app/v1/squish \
  -H "Authorization: Bearer sq_live_…" \
  -F "video=@clip.mov" \
  -F "density=3x3"
```

ฟิลด์เพิ่มเติม: `density` (`3x3`–`6x6`, ค่าเริ่มต้น `3x3` — ยิ่ง density สูง ยิ่งใช้เครดิตต่อแผ่นมากขึ้น) และ `การตอบกลับ` (`json` ค่าเริ่มต้น, หรือ `รูปภาพ` เพื่อรับ JPG ของแผ่นแรกกลับมาโดยตรง พร้อมข้อมูลเมตาใน `x-squish-job` และ `x-credits-remaining` ส่วนหัว).

## การตอบกลับ

```json
{
  "job_id": "...",
  "input": "clip.mov",
  "duration": 10.0,
  "frames": 9,
  "sheets": 1,
  "density": "3x3",
  "credits_charged": 1,
  "credits_remaining": 33,
  "files": ["https://api.getsquish.app/v1/sheets/<job_id>/video.sheet-1.jpg"],
  "timecodes": [["0:00", "0:01", "0:02", "0:03", "0:05", "0:06", "0:07", "0:08", "0:10"]],
  "warnings": [],
  "contract": "squish-http-v0"
}
```

คำขอแบบซิงโครนัสเพียงครั้งเดียวครอบคลุมวงจรทั้งหมด — ไม่มีคิวงาน ไม่มีการโพล และไม่มีเว็บฮุก; การเชื่อมต่อจะค้างเปิดตลอดระยะเวลา (โดยทั่วไปเป็นไม่กี่วินาทีสำหรับคลิปทั่วไป) `job_id` คือใบเสร็จ: มันจะปรากฏใน URL ของแผ่น และในตารางการใช้งานของคุณบน [getsquish.app/api-keys](https://getsquish.app/api-keys). ส่วน `สัญญา` ฟิลด์ (`squish-http-v0`) คือเครื่องหมายเวอร์ชัน — ให้วิเคราะห์เพื่อใช้ตรวจจับการเปลี่ยนแปลงที่ทำให้ใช้งานเดิมไม่ได้

## เครดิตและโควต้าฟรีรายวัน

เครดิตเป็นแบบจ่ายล่วงหน้า และคิดตามแผ่นผลลัพธ์ตาม density: `3x3` = 1 · `4x4` = 2 · `5x5` = 3 · `6x6` = 5. ค่าบริการที่แน่นอนจะทราบ **ก่อน** ที่จะแยกเฟรมใด ๆ ออกมา; หากเอนจินล้มเหลวหลังหักเงิน ระบบจะคืนเครดิตให้อัตโนมัติ

บัญชีที่ **ไม่เคยซื้ออะไรเลย** (ไม่มี web Pro และไม่มีแพ็กเครดิต) จะถูกเติมขึ้นไปถึงขั้นต่ำเล็ก ๆ — ปัจจุบันคือ **7 เครดิต** — มากสุดเพียงครั้งเดียวต่อ **วัน UTC**, ในคำขอที่มีการคิดเงินครั้งแรกของวันซึ่งพบว่ายอดคงเหลือต่ำกว่าขั้นต่ำ เป็นการเติมให้ถึงขั้นต่ำ ไม่ใช่การเพิ่มทีละหน่วย: โควต้าที่ไม่ได้ใช้จะไม่สะสม ไม่มีการให้เพิ่มเมื่อยอดถึงหรือสูงกว่าขั้นต่ำ และยอดที่ซื้อไว้จะไม่ถูกแตะต้อง

## ข้อจำกัดที่ควรรู้

* ขนาดอัปโหลดสูงสุด: **300 MB**. ระยะเวลาสูงสุด: **30 นาที**.
* ประมวลผลงานได้ครั้งละหนึ่งงาน พร้อมคิวสั้น ๆ — หากโหลดเกินจะส่งกลับ `429 busy` (ไม่คิดเครดิต; ลองใหม่ได้อย่างปลอดภัยหลังประมาณ 10–30 วินาที).
* **ไม่มี `จุดเริ่มต้น`/`จุดสิ้นสุด` ยังไม่มีหน้าต่าง** คำขอแบบโฮสต์จะครอบคลุมคลิปทั้งหมดเสมอ; `จุดเริ่มต้น`/`จุดสิ้นสุด` ฟิลด์จะถูกละเลย เครื่องมือในเครื่อง [CLI](/squish/th/getting-started/quickstart-cli.md) และ [MCP server](/squish/th/getting-started/quickstart-mcp.md) รับ `จุดเริ่มต้น`/`จุดสิ้นสุด` สำหรับ [ลูปการนำทาง](/squish/th/the-primitive/the-navigation-loop.md).
* ความพร้อมใช้งาน: `GET https://api.getsquish.app/healthz` (ไม่ต้องยืนยันตัวตน) — ใช้แยก "API ล่ม" ออกจาก "คำขอของฉันผิด"

ตารางข้อผิดพลาดแบบเต็ม (`401` / `402` / `413` / `422` / `429` / `500` พร้อม `เครดิตที่คืน` ฟิลด์) และนโยบายการลองใหม่อยู่ใน [เอกสารอ้างอิง HTTP API](/squish/th/reference/http-api.md).

## ถัดไป

* [เอกสารอ้างอิง HTTP API](/squish/th/reference/http-api.md) — ข้อผิดพลาด นโยบายการลองใหม่ ข้อจำกัด และสัญญาที่ล็อกไว้
* [ความเป็นส่วนตัวและการไหลของข้อมูล](/squish/th/the-primitive/privacy-and-data-flow.md) — ความแตกต่างของเส้นทางการประมวลผลทั้งสามแบบ (เว็บ, CLI/MCP ในเครื่อง, และ hosted API)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://getsquish.gitbook.io/squish/th/getting-started/quickstart-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
