{"_id":"@agentic/openai-fetch","_rev":"2-d0b575e8026af7f5524fd235b6ad3cf6","name":"@agentic/openai-fetch","dist-tags":{"latest":"1.5.3"},"versions":{"1.5.1":{"name":"@agentic/openai-fetch","version":"1.5.1","description":"OpenAI client powered by fetch","types":"dist/index.d.ts","main":"dist/index.cjs.js","module":"dist/index.js","repository":{"type":"git","url":"git+https://github.com/rileytomasek/openai-fetch.git"},"author":{"name":"Riley Tomasek","email":"hi@rile.yt","url":"https://rile.yt"},"scripts":{"build":"rm -rf dist && node build.js && tsc -b","lint":"eslint src","prepare":"yarn build","prepublishOnly":"yarn lint && yarn typecheck","release":"np","typecheck":"tsc"},"license":"MIT","private":false,"dependencies":{"ky":"^0.33.3","zod":"^3.21.2"},"devDependencies":{"@types/node":"^18.14.6","dotenv":"^16.0.3","esbuild":"^0.17.11","eslint":"^8.35.0","eslint-config-hckrs":"^0.0.3","np":"^7.6.3","openai":"^3.2.1","prettier":"^2.8.4","tsx":"^3.12.3","type-fest":"^3.6.1","typescript":"^4.9.5"},"publishConfig":{"registry":"https://registry.npmjs.org"},"prettier":{"singleQuote":true},"gitHead":"b5044aebf1db061004e88cb21e5fee8d267f416f","bugs":{"url":"https://github.com/rileytomasek/openai-fetch/issues"},"homepage":"https://github.com/rileytomasek/openai-fetch#readme","_id":"@agentic/openai-fetch@1.5.1","_nodeVersion":"19.6.1","_npmVersion":"9.4.0","dist":{"integrity":"sha512-AUNLrTupJqB/bKeNv4qtKdwDugZ86+OZ/qOKPzhXJYM8UScbj4YPx0ldSbMHsmgeh2At+JlE9HMHPF0HiyRLfw==","shasum":"921adf30707e2707b7822578b8fd980e0517a87d","tarball":"https://registry.npmjs.org/@agentic/openai-fetch/-/openai-fetch-1.5.1.tgz","fileCount":25,"unpackedSize":891983,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDuAN0sIqqea0tLJkxokldLxH7/FXKxjmAO0qn+SiV6+QIgOq21ZfZYtBmJIJpczLGh6aggrqfZNHYT2jYUvdM/GRw="}]},"_npmUser":{"name":"fisch0920","email":"fisch0920@gmail.com"},"directories":{},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/openai-fetch_1.5.1_1686704921112_0.5396895348992159"},"_hasShrinkwrap":false},"1.5.2":{"name":"@agentic/openai-fetch","version":"1.5.2","description":"OpenAI client powered by fetch","types":"dist/index.d.ts","main":"dist/index.cjs.js","module":"dist/index.js","repository":{"type":"git","url":"https://github.com/rileytomasek/openai-fetch.git"},"author":{"name":"Riley Tomasek","email":"hi@rile.yt","url":"https://rile.yt"},"scripts":{"build":"rm -rf dist && node build.js && tsc -b","lint":"eslint src","prepare":"yarn build","prepublishOnly":"yarn lint && yarn typecheck","release":"np","typecheck":"tsc"},"license":"MIT","private":false,"dependencies":{"ky":"^0.33.3","zod":"^3.21.2"},"devDependencies":{"@types/node":"^18.14.6","dotenv":"^16.0.3","esbuild":"^0.17.11","eslint":"^8.35.0","eslint-config-hckrs":"^0.0.3","np":"^7.6.3","openai":"^3.2.1","prettier":"^2.8.4","tsx":"^3.12.3","type-fest":"^3.6.1","typescript":"^4.9.5"},"publishConfig":{"registry":"https://registry.npmjs.org"},"prettier":{"singleQuote":true},"licenseText":"MIT License\n\nCopyright (c) 2022 Riley Tomasek\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@agentic/openai-fetch@1.5.2","dist":{"shasum":"f8602941e01979245a1d28c9e747c7586f7fbb8d","integrity":"sha512-oJvinEf1pcY03v50UQeG+OQ1farU9lNJD2Mk3qMDpqWzXdAXD2U08IAXMDi6dTULlUPcrggLzQ6+k8dQKtE4vw==","tarball":"https://registry.npmjs.org/@agentic/openai-fetch/-/openai-fetch-1.5.2.tgz","fileCount":28,"unpackedSize":892533,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD54EoBM/xQgq45Yr+eJqjeX+BE9GOLzVyEr20mKuCd6wIgQPRkpHBtAv+f7MAzzn+dJCS+FJNKxNUrTaM2N8jQVHA="}]},"_npmUser":{"name":"fisch0920","email":"fisch0920@gmail.com"},"directories":{},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/openai-fetch_1.5.2_1686707694532_0.7874092913295261"},"_hasShrinkwrap":false},"1.5.3":{"name":"@agentic/openai-fetch","version":"1.5.3","description":"OpenAI client powered by fetch","types":"dist/index.d.ts","main":"dist/index.cjs.js","module":"dist/index.js","repository":{"type":"git","url":"https://github.com/rileytomasek/openai-fetch.git"},"author":{"name":"Riley Tomasek","email":"hi@rile.yt","url":"https://rile.yt"},"scripts":{"build":"rm -rf dist && node build.js && tsc -b","lint":"eslint src","prepare":"yarn build","prepublishOnly":"yarn lint && yarn typecheck","release":"np","typecheck":"tsc"},"license":"MIT","private":false,"dependencies":{"ky":"^0.33.3","zod":"^3.21.2"},"devDependencies":{"@types/node":"^18.14.6","dotenv":"^16.0.3","esbuild":"^0.17.11","eslint":"^8.35.0","eslint-config-hckrs":"^0.0.3","np":"^7.6.3","openai":"^3.2.1","prettier":"^2.8.4","tsx":"^3.12.3","type-fest":"^3.6.1","typescript":"^4.9.5"},"publishConfig":{"registry":"https://registry.npmjs.org"},"prettier":{"singleQuote":true},"licenseText":"MIT License\n\nCopyright (c) 2022 Riley Tomasek\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@agentic/openai-fetch@1.5.3","dist":{"shasum":"3120e78cbd7f62d0f4762a4f96790698f178fe6b","integrity":"sha512-4c5YWz6jQdGxxM+SVhf0XW3mKYnFr56hntPep+y7wRfkjUl6lgZiuU3J61esQ8bj8vSFkgSfwjf3DeZIi/IEsg==","tarball":"https://registry.npmjs.org/@agentic/openai-fetch/-/openai-fetch-1.5.3.tgz","fileCount":28,"unpackedSize":892773,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCALZ+7LpZuAv57Xw450EyT7T5lU6arZbs/CVAlNmbtmgIgGQJ0fWA/dKwb/xvcpZ5fhxKbs+Dy8/1xwzbfGMhXmXA="}]},"_npmUser":{"name":"fisch0920","email":"fisch0920@gmail.com"},"directories":{},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/openai-fetch_1.5.3_1686710279528_0.3740544268605617"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-14T01:08:41.013Z","1.5.1":"2023-06-14T01:08:41.391Z","modified":"2023-06-14T02:37:59.832Z","1.5.2":"2023-06-14T01:54:54.905Z","1.5.3":"2023-06-14T02:37:59.712Z"},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"description":"OpenAI client powered by fetch","repository":{"type":"git","url":"https://github.com/rileytomasek/openai-fetch.git"},"author":{"name":"Riley Tomasek","email":"hi@rile.yt","url":"https://rile.yt"},"license":"MIT","readme":"# OpenAI Fetch Client\n\n[![Build Status](https://github.com/rileytomasek/openai-fetch/actions/workflows/main.yml/badge.svg)](https://github.com/rileytomasek/openai-fetch/actions/workflows/main.yml) [![npm version](https://img.shields.io/npm/v/openai-fetch.svg?color=0c0)](https://www.npmjs.com/package/openai-fetch)\n\nA minimal and opinionated OpenAI client powered by fetch.\n\nUnfortunately, the official [openai-node](https://github.com/openai/openai-node) uses Axios, which only supports Node and is bloated.\n\n### Reasons to consider using `openai-fetch`:\n\n- Supports all envs with native fetch: Node 18+, browsers, Deno, Cloudflare Workers, etc\n- Package size: `openai-fetch` is [~5kb](https://bundlephobia.com/package/openai-fetch) and `openai-node` is [~180kb](https://bundlephobia.com/package/openai-node)\n- `openai-fetch` includes the first choice in the response (no repetitive: `response.choices[0.text]`)\n- You only need the completions, edits, and embeddings endpoints\n\n### Use `openai-node` if you need:\n\n- Endpoints other than completions, edits, and embeddings\n- Streaming response support (this may be added later)\n- Responses to contain more than one choice (no `n` support)\n- To use tokens instead of strings for input\n\n## Usage\n\nInstall `openai-fetch` with your favorite package manager and create an instance of the `OpenAIClient` class.\n\n```ts\nimport { OpenAIClient } from 'openai-fetch';\n\nconst client = new OpenAIClient({ apiKey: '<your api key>' });\n```\n\nThe `apiKey` is optional and will be read from `process.env.OPENAI_API_KEY` if present.\n\n## API\n\nThe API follows OpenAI very closely, so their [reference documentation](https://beta.openai.com/docs/api-reference) can generally be used. Everything is strongly typed, so you will know if anything is different as soon as TypeScript parses your code.\n\n### Create Completion\n\nSee: [OpenAI docs](https://beta.openai.com/docs/api-reference/completions) | [Type definitions](/src/schemas/completion.ts)\n\n```ts\nclient.createCompletion(params: CompletionParams): Promise<{\n  /** The completion string. */\n  completion: string;\n  /** The raw response from the API. */\n  response: CompletionResponse;\n}>\n```\n\nTo get a streaming response, use the `streamCompletion` method.\n\n```ts\nclient.streamCompletion(params: CompletionParams): Promise<\n    ReadableStream<{\n      /** The completion string. */\n      completion: string;\n      /** The raw response from the API. */\n      response: CompletionResponse;\n    }>\n  >\n```\n\n### Create Chat Completion\n\nSee: [OpenAI docs](https://beta.openai.com/docs/api-reference/chat) | [Type definitions](/src/schemas/chat-completion.ts)\n\n```ts\nclient.createChatCompletion(params: ChatCompletionParams): Promise<{\n  /** The completion message. */\n  message: ChatResponseMessage;\n  /** The raw response from the API. */\n  response: ChatCompletionResponse;\n}>\n```\n\n### Create Embedding\n\nSee: [OpenAI docs](https://beta.openai.com/docs/api-reference/embeddings) | [Type definitions](/src/schemas/embedding.ts)\n\n```ts\nclient.createEmbedding(params: EmbeddingParams): Promise<{\n  /** The embedding for the input string. */\n  embedding: number[];\n  /** The raw response from the API. */\n  response: EmbeddingResponse;\n}>\n```\n\n### Create Edit\n\nSee: [OpenAI docs](https://beta.openai.com/docs/api-reference/edits) | [Type definitions](/src/schemas/edit.ts)\n\n```ts\nclient.createEdit(params: EditParams): Promise<{\n  /** The edited input string. */\n  completion: string;\n  /** The raw response from the API. */\n  response: EditResponse;\n}>\n```\n","readmeFilename":"readme.md"}