{"_id":"deepinfra","_rev":"2-affb4799921626ffb7b8deb0d9836e5d","name":"deepinfra","dist-tags":{"latest":"2.2.0"},"versions":{"2.0.2":{"name":"deepinfra","version":"2.0.2","keywords":["llm","deepinfra","api","wrapper","typesript","large language model","deep learning","machine learning","artificial intelligence","ai"],"author":{"url":"https://www.oguzvuruskaner.com","name":"Oguz Vuruskaner","email":"ovuruska@gmail.com"},"license":"MIT","_id":"deepinfra@2.0.2","maintainers":[{"name":"iskren-deepinfra","email":"iskren@deepinfra.com"}],"homepage":"https://github.com/deepinfra/deepinfra-node#readme","bugs":{"url":"https://github.com/deepinfra/deepinfra-node/issues"},"dist":{"shasum":"4f9c0710ef49e8a7cee2c10c6afe0740c8a8fcdd","tarball":"https://registry.npmjs.org/deepinfra/-/deepinfra-2.0.2.tgz","fileCount":115,"integrity":"sha512-M/N9dqwnY77WGuPhHBVWYZwv/XK11WFJdLcOvDqK4RMGvoFRSMpTwo23TZkFtxLb9j3/HoYrwTgdLWWkeIkBQQ==","signatures":[{"sig":"MEYCIQDWL9P/FZGZanBPCAD5E3sBESfaHVzjUT5jsC1Q1f4d4QIhAKlvgYCBl22/6F0qre5kFN832CGLHZcW75Y4IOkIk53F","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":57301},"main":"dist/index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"a7c6b37831860aa6f10351e5cbf084ab034a6f0d","scripts":{"lint":"eslint . --ext .ts --fix","misc":"npx ts-node -r tsconfig-paths/register src/misc.ts","test":"jest --passWithNoTests","build":"tsc && tsc-alias -p tsconfig.json","prepare":"husky","prettier":"prettier --write ./src ./test && prettier --write README.MD","build-docs":"typedoc --out docs src","deploy-docs":"npx gh-pages -d docs","predeploy-docs":"npm run build-docs"},"_npmUser":{"name":"iskren-deepinfra","email":"iskren@deepinfra.com"},"repository":{"url":"git+https://github.com/deepinfra/deepinfra-node.git","type":"git"},"_npmVersion":"10.5.0","description":"Official API wrapper for DeepInfra","directories":{},"_nodeVersion":"18.20.2","dependencies":{"axios":"^1.6.7","@swc/core":"^1.4.6","@swc/wasm":"^1.4.6","form-data":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^9.0.11","dotenv":"^16.4.5","eslint":"^8.57.0","ts-jest":"^29.1.2","ts-node":"^10.9.2","typedoc":"^0.25.12","prettier":"^3.2.5","tsc-alias":"^1.8.8","typescript":"^5.4.2","@types/jest":"^29.5.12","@types/node":"^20.11.26","tsconfig-paths":"^4.2.0","eslint-plugin-unicorn":"^51.0.1","@typescript-eslint/parser":"^7.2.0","cz-conventional-changelog":"^3.3.0","@typescript-eslint/eslint-plugin":"^7.2.0"},"_npmOperationalInternal":{"tmp":"tmp/deepinfra_2.0.2_1715164838543_0.76336385679089","host":"s3://npm-registry-packages"}},"2.2.0":{"_id":"deepinfra@2.2.0","bugs":{"url":"https://github.com/deepinfra/deepinfra-node/issues"},"dist":{"shasum":"2813b8cbd6bca61515e7a540304f4c740dafd9e8","tarball":"https://registry.npmjs.org/deepinfra/-/deepinfra-2.2.0.tgz","integrity":"sha512-SdTt1yvKUIwJeHgFLSfecVgPIt7DN36EOb9m6paBgQ7alfIDVQiXbEkZli7LDuotPLVubb+MF3WIOKGkcffLrw==","fileCount":155,"unpackedSize":119879,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/deepinfra@2.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICMdYKG7TEmF68VodtiEutmVu+acQBgw535r70vuhNfUAiEAohRk+dG9RlsiIBbnmZ/2NqxLOdu0t7I6cfbCFKkNvwE="}]},"main":"dist/index.js","name":"deepinfra","types":"dist/index.d.ts","author":{"url":"https://www.oguzvuruskaner.com","name":"Oguz Vuruskaner","email":"ovuruska@gmail.com"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"4fdf685bcf9a3c30a8c1d66f6e776b98ccab1e6e","license":"MIT","scripts":{"lint":"eslint . --ext .ts --fix","misc":"npx ts-node -r tsconfig-paths/register src/misc.ts","test":"jest --passWithNoTests","build":"tsc && tsc-alias -p tsconfig.json","prepare":"husky","prettier":"prettier --write ./src ./test && prettier --write README.MD","build-docs":"typedoc --out docs src","deploy-docs":"npx gh-pages -d docs","predeploy-docs":"npm run build-docs"},"version":"2.2.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"0ccda263-c37e-42a0-8201-75389b4c9e50"},"approver":{"name":"iskren-deepinfra","email":"iskren@deepinfra.com"}},"homepage":"https://github.com/deepinfra/deepinfra-node#readme","keywords":["llm","deepinfra","api","wrapper","sandbox","typescript","large language model","deep learning","machine learning","artificial intelligence","ai"],"repository":{"url":"git+https://github.com/deepinfra/deepinfra-node.git","type":"git"},"_npmVersion":"11.19.1","description":"Official API wrapper for DeepInfra","directories":{},"maintainers":[{"name":"iskren-deepinfra","email":"iskren@deepinfra.com"}],"_nodeVersion":"24.22.2","dependencies":{"axios":"^1.20.0","form-data":"^4.0.6"},"devDependencies":{"jest":"^29.7.0","husky":"^9.0.11","dotenv":"^16.4.5","eslint":"^8.57.0","ts-jest":"^29.1.2","ts-node":"^10.9.2","typedoc":"^0.25.12","prettier":"^3.2.5","tsc-alias":"^1.8.8","typescript":"^5.4.2","@types/jest":"^29.5.12","@types/node":"^20.11.26","tsconfig-paths":"^4.2.0","eslint-plugin-unicorn":"^51.0.1","@typescript-eslint/parser":"^7.2.0","cz-conventional-changelog":"^3.3.0","@typescript-eslint/eslint-plugin":"^7.2.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/deepinfra_2.2.0_1794485443932_0.3174436362054922"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-08T10:40:38.417Z","modified":"2026-11-12T12:10:44.390Z","2.0.2":"2024-05-08T10:40:38.782Z","2.2.0":"2026-11-12T12:10:44.018Z"},"bugs":{"url":"https://github.com/deepinfra/deepinfra-node/issues"},"author":{"url":"https://www.oguzvuruskaner.com","name":"Oguz Vuruskaner","email":"ovuruska@gmail.com"},"license":"MIT","homepage":"https://github.com/deepinfra/deepinfra-node#readme","keywords":["llm","deepinfra","api","wrapper","sandbox","typescript","large language model","deep learning","machine learning","artificial intelligence","ai"],"repository":{"url":"git+https://github.com/deepinfra/deepinfra-node.git","type":"git"},"description":"Official API wrapper for DeepInfra","maintainers":[{"name":"iskren-deepinfra","email":"iskren@deepinfra.com"}],"readme":"# DeepInfra Node API Library\n![npm](https://img.shields.io/npm/v/deepinfra)\n![npm](https://img.shields.io/npm/dt/deepinfra)<br>\n\n\nThis library provides a simple way to interact with the DeepInfra API. \n<br>\n<br>\nCheck out our docs [here.](https://deepinfra.github.io/deepinfra-node/)\n\n## Installation\n\n```bash\nnpm install deepinfra\n```\n\n## Sandboxes\n\nCreate an isolated Linux microVM, run bash/python inside it, move files in and\nout, and tear it down — in a few lines:\n\n```typescript\nimport { Sandbox } from \"deepinfra\";\n\nconst sb = await Sandbox.create({ plan: \"medium\", timeout: \"10m\" }); // resolves once running\n\nconst r = await sb.exec(\n  \"bash\",\n  \"-c\",\n  \"pip install --break-system-packages pandas && python3 -c 'import pandas; print(pandas.__version__)'\",\n);\nconsole.log(r.stdout, r.stderr, r.returncode);\n\nconst out = await sb.runPython(\"print(21 * 2)\");\nout.check(); // throws CommandFailedError on a non-zero exit code\n\nawait sb.fs.write(\"/workspace/in.csv\", \"a,b\\n1,2\\n\");\nconst data = await sb.fs.read(\"/workspace/in.csv\"); // Buffer\n\nawait sb.stop(); // frees compute, keeps disk; resolves once stopped\nawait sb.start(); // resumes on the same disk; resolves once running\nawait sb.terminate(); // deletes the sandbox (stays fetchable by id as \"deleted\" briefly)\n```\n\n`/workspace` is the only path `fs.write`/`fs.read` accept, and it's the only\npart of the filesystem that survives `stop()`/`start()` — everything else\n(e.g. packages installed with `pip`/`apt` outside it) resets to the base\nimage on restart, and the sandbox's idle timeout has the same effect as an\nexplicit `stop()`.\n\nStream output while a command runs — the last event carries the exit code:\n\n```typescript\nfor await (const event of sb.execStream(\n  \"bash\",\n  \"-c\",\n  \"pip install --break-system-packages requests\",\n  { timeout: \"5m\" },\n)) {\n  if (event.type === \"stdout\") process.stdout.write(event.data);\n  else if (event.type === \"stderr\") process.stderr.write(event.data);\n  else console.log(\"exit code\", event.returncode);\n}\n```\n\n`exec()` and `execStream()` also take an `AbortSignal` (`{ signal }`). Aborting\nmakes the pending call or loop throw the signal's reason. Neither aborting nor\nleaving an `execStream()` loop early (`break`, `return` or an exception) stops\nthe command: it keeps running in the sandbox until it exits or reaches its\n`timeout` (60 seconds by default).\n\nAuto-terminate with `try`/`finally`:\n\n```typescript\nconst sb = await Sandbox.create({ plan: \"small\" });\ntry {\n  await sb.runPython(\"open('/workspace/out.txt', 'w').write('hi')\");\n  console.log((await sb.fs.read(\"/workspace/out.txt\")).toString());\n} finally {\n  await sb.terminate();\n}\n```\n\nOther lookups:\n\n```typescript\nimport fs from \"node:fs\";\n\n// Find existing sandboxes\nconst sb = await Sandbox.fromId(\"sb_...\");\nconst etlBoxes = await Sandbox.list({ tags: { job: \"etl-42\" } });\n\n// List available plans (id, vcpu, ram_gb, disk_gb, price_per_hour)\nfor (const plan of await Sandbox.catalog()) {\n  console.log(plan.id, plan.vcpu, plan.ram_gb, plan.price_per_hour);\n}\n\n// Large scripts: upload, then run\nawait sb.fs.write(\n  \"/workspace/script.py\",\n  await fs.promises.readFile(\"script.py\", \"utf8\"),\n);\nawait sb.exec(\"python3\", \"/workspace/script.py\", { timeout: \"30m\" });\n```\n\nErrors are typed: `AuthenticationError` (401), `NotFoundError` (404),\n`ConflictError` (409, e.g. exec on a stopped sandbox), `RateLimitError`\n(429; for sandboxes that's the per-account cap — `TooManySandboxesError` is\nan alias), `CapacityError` (503), plus SDK-side `SandboxTimeoutError` /\n`SandboxFailedError` / `CommandFailedError`. If `Sandbox.create()` fails\nwhile waiting for it to come up, the raised error carries `.sandboxId` so you\ncan inspect or terminate the sandbox it created.\n\nSee [`examples/sandbox-quickstart.ts`](examples/sandbox-quickstart.ts) for a runnable end-to-end example.\n\n## Usage\n\n### Use [text generation models](https://deepinfra.com/models/text-generation)\n\nThe Mixtral mixture of expert model, developed by Mistral AI, is an innovative experimental machine learning model that\nleverages a mixture of 8 experts (MoE) within 7b models. Its release was facilitated via a torrent, and the model's\nimplementation remains in the experimental phase.\\_\n\n```typescript\nimport {TextGeneration} from \"deepinfra\";\n\nconst modelName = \"mistralai/Mixtral-8x22B-Instruct-v0.1\";\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst main = async () => {\n  const mixtral = new TextGeneration(modelName, apiKey);\n  const body = {\n    input: \"What is the capital of France?\",\n  };\n  const output = await mixtral.generate(body);\n  const text = output.results[0].generated_text;\n  console.log(text);\n};\n\nmain();\n```\n\n### Use [text embedding models](https://deepinfra.com/models/embeddings)\n\nGte Base is an text embedding model that generates embeddings for the input text. The model is trained by Alibaba DAMO Academy.\n\n```typescript\nimport { GteBase } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"thenlper/gte-base\";\nconst main = async () => {\n  const gteBase = new Embeddings(modelName, apiKey);\n  const body = {\n    inputs: [\n      \"What is the capital of France?\",\n      \"What is the capital of Germany?\",\n      \"What is the capital of Italy?\",\n    ],\n  };\n  const output = await gteBase.generate(body);\n  const embeddings = output.embeddings[0];\n  console.log(embeddings);\n};\n\nmain();\n```\n\n### Use [SDXL](https://deepinfra.com/stability-ai/sdxl) to generate images\n\nSDXL requires unique parameters, therefore it requires different initialization.\n\n```typescript\nimport { Sdxl } from \"deepinfra\";\nimport axios from \"axios\";\nimport fs from \"fs\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\n\nconst main = async () => {\n  const model = new Sdxl(apiKey);\n\n  const input = {\n    prompt: \"The quick brown fox jumps over the lazy dog with\",\n  };\n  const response = await model.generate({ input });\n  const { output } = response;\n  const image = output[0];\n\n  await axios.get(image, { responseType: \"arraybuffer\" }).then((response) => {\n    fs.writeFileSync(\"image.png\", response.data);\n  });\n};\n\nmain();\n```\n\n### Use [other text to image models](https://deepinfra.com/models/text-to-image)\n\n```typescript\nimport { TextToImage } from \"deepinfra\";\nimport axios from \"axios\";\nimport fs from \"fs\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"stabilityai/stable-diffusion-2-1\";\nconst main = async () => {\n  const model = new TextToImage(modelName, apiKey);\n  const input = {\n    prompt: \"The quick brown fox jumps over the lazy dog with\",\n  };\n\n  const response = await model.generate(input);\n  const { output } = response;\n  const image = output[0];\n\n  await axios.get(image, { responseType: \"arraybuffer\" }).then((response) => {\n    fs.writeFileSync(\"image.png\", response.data);\n  });\n};\nmain();\n```\n\n### Use [automatic speech recognition models](https://deepinfra.com/models/automatic-speech-recognition)\n\n```typescript\nimport { AutomaticSpeechRecognition } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"openai/whisper-base\";\n\nconst main = async () => {\n  const model = new AutomaticSpeechRecognition(modelName, apiKey);\n\n  const input = {\n    audio: path.join(__dirname, \"audio.mp3\"),\n  };\n  const response = await model.generate(input);\n  const { text } = response;\n  console.log(text);\n};\n\nmain();\n```\n\n### Use [object detection models](https://deepinfra.com/models/object-detection)\n\n```typescript\nimport { ObjectDetection } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"hustvl/yolos-tiny\";\nconst main = async () => {\n  const model = new ObjectDetection(modelName, apiKey);\n\n  const input = {\n    image: path.join(__dirname, \"image.jpg\"),\n  };\n  const response = await model.generate(input);\n  const { results } = response;\n  console.log(results);\n};\n```\n\n### Use [token classification models](https://deepinfra.com/models/token-classification)\n\n```typescript\nimport { TokenClassification } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"Davlan/bert-base-multilingual-cased-ner-hrl\";\n\nconst main = async () => {\n  const model = new TokenClassification(modelName, apiKey);\n\n  const input = {\n    text: \"The quick brown fox jumps over the lazy dog\",\n  };\n  const response = await model.generate(input);\n  const { results } = response;\n  console.log(results);\n};\n```\n\n### Use [fill mask models](https://deepinfra.com/models/fill-mask)\n\n```typescript\nimport { FillMask } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"GroNLP/bert-base-dutch-cased\";\n\nconst main = async () => {\n  const model = new FillMask(modelName, apiKey);\n\n  const body = {\n    input: \"Ik heb een [MASK] gekocht.\",\n  };\n\n  const { results } = await model.generate(body);\n  console.log(results);\n};\n```\n\n### Use [image classification models](https://deepinfra.com/models/image-classification)\n\n```typescript\nimport { ImageClassification } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"google/vit-base-patch16-224\";\n\nconst main = async () => {\n  const model = new ImageClassification(modelName, apiKey);\n\n  const body = {\n    image: path.join(__dirname, \"image.jpg\"),\n  };\n\n  const { results } = await model.generate(body);\n  console.log(results);\n};\n```\n\n### Use [zero-shot image classification models](https://deepinfra.com/models/zero-shot-image-classification)\n\n```typescript\nimport { ZeroShotImageClassification } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"openai/clip-vit-base-patch32\";\n\nconst main = async () => {\n  const model = new ZeroShotImageClassification(modelName, apiKey);\n\n  const body = {\n    image: path.join(__dirname, \"image.jpg\"),\n    candidate_labels: [\"dog\", \"cat\", \"car\"],\n  };\n\n  const { results } = await model.generate(body);\n  console.log(results);\n};\n```\n\n### Use [text classification models](https://deepinfra.com/models/text-classification)\n\n```typescript\nimport { TextClassification } from \"deepinfra\";\n\nconst apiKey = \"YOUR_DEEPINFRA_API_KEY\";\nconst modelName = \"ProsusAI/finbert\";\n\nconst misc = async () => {\n  const model = new TextClassification(apiKey);\n\n  const body = {\n    input:\n      \"DeepInfra emerges from stealth with $8M to make running AI inferences more affordable\",\n  };\n\n  const { results } = await model.generate(body);\n  console.log(results);\n};\n```\n\n## Contributors\n\n[Oguz Vuruskaner](https://github.com/ovuruska)\n\n[Iskren Ivov Chernev](https://github.com/ichernev)\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull\nrequests to us.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","readmeFilename":"README.MD"}