설치 및 첫 세션 실행
Dropstone SDK를 설치하고, API 키로 헤드리스 API 호출을 수행하며, 계정 메모리를 유지하는 로컬 에이전트 세션을 실행합니다. 스트리밍, 구조화된 출력, OpenAI SDK를 Dropstone에 사용하는 방법을 포함합니다.
두 가지 클라이언트, 두 가지 첫 호출. 코드가 실행되는 위치에 맞는 것을 선택하세요. SDK 개요에서 차이점을 설명합니다.
헤드리스: 어디서든 호출
- 설정의 API 키 아래에 있는 대시보드에서 API 키를 생성하세요.
dsk_live_...형식이며 한 번만 표시됩니다. - SDK 설치:
npm install @blankline/dropstone-sdk. - 키를 환경 변수
DROPSTONE_API_KEY로 설정하세요. 비밀번호처럼 취급하세요: 절대 커밋하지 말고, 브라우저 번들에 포함하지 마세요. - 호출하세요. 클라이언트가 환경 변수를 자동으로 읽습니다.
import { createDropstoneApi } from "@blankline/dropstone-sdk"
const dropstone = createDropstoneApi()
const resp = await dropstone.chat.completions.create({
model: "dropstone-fast",
messages: [{ role: "user", content: "Summarise this changelog entry." }],
})
console.log(resp.choices[0].message.content)
stream: true를 추가하면 동일한 호출이 청크의 비동기 반복자를 반환합니다. UI나 긴 답변에서 원하는 방식입니다:
const stream = await dropstone.chat.completions.create({
model: "dropstone-fast",
stream: true,
messages: [{ role: "user", content: "Count to five." }],
})
for await (const chunk of stream) {
process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "")
}
엔드포인트는 OpenAI 호환 방식이므로 기존 클라이언트도 Dropstone을 가리키도록 설정하면 작동합니다:
import OpenAI from "openai"
const openai = new OpenAI({
baseURL: "https://api.dropstone.io/api/v1",
apiKey: process.env.DROPSTONE_API_KEY,
})
API 키 요청은 플랜 허용량이 아닌 크레딧 잔액에서 종량제로 청구되며, 잔액이 없는 키는 충전 링크와 함께 거부됩니다. 플랜과 함께 API 사용하기를 참조하세요.
로컬: 프로세스 안의 에이전트
로컬 클라이언트는 dropstone serve 프로세스를 시작하고, 이를 가리키는 타입이 지정된 클라이언트를 제공하며, 작업이 끝나면 종료합니다. 계정으로 실행되므로 세션은 사용자의 메모리를 유지합니다.
- Dropstone CLI를 설치하고
dropstone login으로 로그인하세요. SDK는 동일한 로그인을 읽습니다. - 세션을 만든 다음 프롬프트를 보내세요.
import { createDropstone } from "@blankline/dropstone-sdk"
const { client, server } = await createDropstone()
const session = await client.session.create({
body: { agent: "build", model: { providerID: "dropstone", modelID: "dropstone-pro" } },
})
const reply = await client.session.prompt({
path: { id: session.data.id },
body: { parts: [{ type: "text", text: "Hello, who are you?" }] },
})
console.log(reply.data)
await server.close()
서버가 이미 실행 중이라면 생성을 건너뛰세요:
import { createDropstoneClient } from "@blankline/dropstone-sdk"
const client = createDropstoneClient({ baseUrl: "http://127.0.0.1:4096" })
팁
- 버전 범위를 고정하세요. SDK는 빠른 주기로 배포되므로 최신 태그 대신 테스트한 범위에 의존하세요.
- 새 코드에는 v2를 사용하세요.
@blankline/dropstone-sdk/v2는 새 엔드포인트가 추가되는 표면이며, v1은 기존 통합을 위해 유지됩니다. - 파이프라인의 학습을 자신의 메모리에서 분리하세요. 헤드리스 호출에는 메모리가 연결되지 않으며, 로컬 세션은 로그인한 계정을 사용합니다. 통합에 자체 메모리가 필요하면 자체 계정을 부여하세요. 모든 표면에서 하나의 메모리를 참조하세요.
제한 사항
- 로컬 클라이언트는 같은 머신에 CLI가 필요합니다. CLI가 없는 호스트는 헤드리스 클라이언트를 사용해야 합니다.
- 헤드리스 엔드포인트는 채팅 완성입니다. 에이전트 루프, 파일 작업, 워크스페이스 도구는 로컬 클라이언트에 있습니다.
Related articles
- Dropstone SDKA typed TypeScript and JavaScript client for the Dropstone agent, with two entry points: one for headless API calls from CI or a serverless function, one that runs the agent locally with the same account memory as the CLI and Chat.
- Using the API with your planCall Dropstone over HTTP with an API key. The endpoint is OpenAI-compatible, billed pay-per-use from your credit balance, and works from any language. Keys, errors, rate limits, and what the API does not carry.
- One memory across every surfaceThe account memory that follows you across Dropstone Chat, the CLI, and the SDK, what shares it and what does not, and how to keep an integration's learning out of your own memory.
- Install the CLIInstall the Dropstone CLI on macOS, Linux, or Windows with one command, sign in, and check it works. Upgrading and uninstalling.
- How to get supportHow to reach Dropstone support, what to include so we can help quickly, and the right address for billing, privacy, security, and enterprise questions.
Ctrl+I