JavaScript SDK
The official JavaScript SDK for Get3W. Works with Node.js and modern browsers.
Installation
bash
npm install get3wQuick Start
javascript
import Get3W from "get3w";
const client = new Get3W({ apiKey: process.env.GET3W_API_KEY });
const output = await client.run("get3w/z-image/turbo", {
prompt: "Cat in space, cinematic lighting",
});
console.log(output.outputs[0]);Authentication
Get your API key from get3w.com/accesskey.
Option 1: Environment variable (recommended)
bash
export GET3W_API_KEY="your-api-key"Option 2: Pass directly
javascript
import Get3W from "get3w";
const client = new Get3W({ apiKey: "your-api-key" });Configuration
Timeout & Polling
javascript
const output = await client.run("get3w/z-image/turbo", {
prompt: "Cat",
}, {
timeout: 36000,
pollInterval: 1000,
});Sync Mode
javascript
const output = await client.run("get3w/z-image/turbo", {
prompt: "Cat",
}, {
syncMode: true,
});File Upload
javascript
const url = await client.upload("/path/to/image.png");
console.log(url);Browser Usage
The SDK can also be used in browser environments. However, you should proxy API requests through your backend to protect your API key.
javascript
const client = new Get3W({
apiKey: "your-api-key",
baseUrl: "https://your-proxy-server.com",
});WARNING
Never expose your API key in client-side code. Always use a server-side proxy.