{"id":19591311,"url":"https://github.com/humanloop/humanloop-node","last_synced_at":"2026-03-17T23:07:49.371Z","repository":{"id":268894532,"uuid":"820924015","full_name":"humanloop/humanloop-node","owner":"humanloop","description":"Official TypeScript SDK for the Humanloop API","archived":false,"fork":false,"pushed_at":"2025-05-23T12:10:19.000Z","size":2296,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-14T13:18:13.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humanloop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-27T12:56:57.000Z","updated_at":"2025-05-20T14:50:21.000Z","dependencies_parsed_at":"2025-01-07T12:30:17.479Z","dependency_job_id":"36bb93f2-7444-4410-b75f-8b5b3fdcb13a","html_url":"https://github.com/humanloop/humanloop-node","commit_stats":null,"previous_names":["humanloop/humanloop-node"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/humanloop/humanloop-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanloop%2Fhumanloop-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanloop%2Fhumanloop-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanloop%2Fhumanloop-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanloop%2Fhumanloop-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humanloop","download_url":"https://codeload.github.com/humanloop/humanloop-node/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanloop%2Fhumanloop-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30635156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T22:38:22.569Z","status":"ssl_error","status_checked_at":"2026-03-17T22:38:11.804Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T08:28:28.815Z","updated_at":"2026-03-17T23:07:49.334Z","avatar_url":"https://github.com/humanloop.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Humanloop TypeScript Library\n\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github\u0026utm_medium=github\u0026utm_campaign=readme\u0026utm_source=https%3A%2F%2Fgithub.com%2Fhumanloop%2Fhumanloop-node)\n[![npm shield](https://img.shields.io/npm/v/humanloop)](https://www.npmjs.com/package/humanloop)\n\nThe Humanloop TypeScript library provides convenient access to the Humanloop API from TypeScript.\n\n## Installation\n\n```sh\nnpm i -s humanloop\n```\n\n## Reference\n\nA full reference for this library is available [here](./reference.md).\n\n## Usage\n\nInstantiate and use the client with the following:\n\n```typescript\nimport { HumanloopClient } from \"humanloop\";\n\nconst client = new HumanloopClient({ apiKey: \"YOUR_API_KEY\" });\nawait client.prompts.log({\n    path: \"persona\",\n    prompt: {\n        model: \"gpt-4\",\n        template: [\n            {\n                role: \"system\",\n                content: \"You are {{person}}. Answer questions as this person. Do not break character.\",\n            },\n        ],\n    },\n    messages: [\n        {\n            role: \"user\",\n            content: \"What really happened at Roswell?\",\n        },\n    ],\n    inputs: {\n        person: \"Trump\",\n    },\n    createdAt: \"2024-07-19T00:29:35.178992\",\n    error: undefined,\n    providerLatency: 6.5931549072265625,\n    outputMessage: {\n        content:\n            \"Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact.\",\n        role: \"assistant\",\n    },\n    promptTokens: 100,\n    outputTokens: 220,\n    promptCost: 0.00001,\n    outputCost: 0.0002,\n    finishReason: \"stop\",\n});\n```\n\n## Request And Response Types\n\nThe SDK exports all request and response types as TypeScript interfaces. Simply import them with the\nfollowing namespace:\n\n```typescript\nimport { Humanloop } from \"humanloop\";\n\nconst request: Humanloop.PromptLogRequest = {\n    ...\n};\n```\n\n## Exception Handling\n\nWhen the API returns a non-success status code (4xx or 5xx response), a subclass of the following error\nwill be thrown.\n\n```typescript\nimport { HumanloopError } from \"humanloop\";\n\ntry {\n    await client.prompts.log(...);\n} catch (err) {\n    if (err instanceof HumanloopError) {\n        console.log(err.statusCode);\n        console.log(err.message);\n        console.log(err.body);\n    }\n}\n```\n\n## Pagination\n\nList endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:\n\n```typescript\nimport { HumanloopClient } from \"humanloop\";\n\nconst client = new HumanloopClient({ apiKey: \"YOUR_API_KEY\" });\nconst response = await client.prompts.list({\n    size: 1,\n});\nfor await (const item of response) {\n    console.log(item);\n}\n\n// Or you can manually iterate page-by-page\nconst page = await client.prompts.list({\n    size: 1,\n});\nwhile (page.hasNextPage()) {\n    page = page.getNextPage();\n}\n```\n\n## Advanced\n\n### Additional Headers\n\nIf you would like to send additional headers as part of the request, use the `headers` request option.\n\n```typescript\nconst response = await client.prompts.log(..., {\n    headers: {\n        'X-Custom-Header': 'custom value'\n    }\n});\n```\n\n### Retries\n\nThe SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long\nas the request is deemed retryable and the number of retry attempts has not grown larger than the configured\nretry limit (default: 2).\n\nA request is deemed retryable when any of the following HTTP status codes is returned:\n\n- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)\n- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)\n- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)\n\nUse the `maxRetries` request option to configure this behavior.\n\n```typescript\nconst response = await client.prompts.log(..., {\n    maxRetries: 0 // override maxRetries at the request level\n});\n```\n\n### Timeouts\n\nThe SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.\n\n```typescript\nconst response = await client.prompts.log(..., {\n    timeoutInSeconds: 30 // override timeout to 30s\n});\n```\n\n### Aborting Requests\n\nThe SDK allows users to abort requests at any point by passing in an abort signal.\n\n```typescript\nconst controller = new AbortController();\nconst response = await client.prompts.log(..., {\n    abortSignal: controller.signal\n});\ncontroller.abort(); // aborts the request\n```\n\n### Runtime Compatibility\n\nThe SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following\nruntimes:\n\n- Node.js 18+\n- Vercel\n- Cloudflare Workers\n- Deno v1.25+\n- Bun 1.0+\n- React Native\n\n### Customizing Fetch Client\n\nThe SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an\nunsupported environment, this provides a way for you to break glass and ensure the SDK works.\n\n```typescript\nimport { HumanloopClient } from \"humanloop\";\n\nconst client = new HumanloopClient({\n    ...\n    fetcher: // provide your implementation here\n});\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically.\nAdditions made directly to this library would have to be moved over to our generation code,\notherwise they would be overwritten upon the next generated release. Feel free to open a PR as\na proof of concept, but know that we will not be able to merge it as-is. We suggest opening\nan issue first to discuss with us!\n\nOn the other hand, contributions to the README are always very welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanloop%2Fhumanloop-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanloop%2Fhumanloop-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanloop%2Fhumanloop-node/lists"}