{"id":20759704,"url":"https://github.com/fal-ai/fal-js","last_synced_at":"2025-04-08T11:08:40.470Z","repository":{"id":149511189,"uuid":"605298083","full_name":"fal-ai/fal-js","owner":"fal-ai","description":"The JavaScript client and utilities to fal-serverless with built-in TypeScript definitions","archived":false,"fork":false,"pushed_at":"2025-03-18T19:46:25.000Z","size":1471,"stargazers_count":108,"open_issues_count":8,"forks_count":23,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-05T22:44:11.660Z","etag":null,"topics":["ai","client","express","ml","nextjs","react-native","serverless","typescript"],"latest_commit_sha":null,"homepage":"https://fal.ai","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fal-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2023-02-22T21:36:31.000Z","updated_at":"2025-04-04T04:06:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7b5c8cb-932b-4f96-b0ae-1b834b31198f","html_url":"https://github.com/fal-ai/fal-js","commit_stats":{"total_commits":118,"total_committers":9,"mean_commits":13.11111111111111,"dds":"0.17796610169491522","last_synced_commit":"a1c780a601beca98c1a7e587b7df75c43d80273f"},"previous_names":["fal-ai/fal-js","fal-ai/serverless-js"],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fal-ai%2Ffal-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fal-ai%2Ffal-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fal-ai%2Ffal-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fal-ai%2Ffal-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fal-ai","download_url":"https://codeload.github.com/fal-ai/fal-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411193,"owners_count":20934650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ai","client","express","ml","nextjs","react-native","serverless","typescript"],"created_at":"2024-11-17T10:07:33.441Z","updated_at":"2025-04-08T11:08:40.444Z","avatar_url":"https://github.com/fal-ai.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# The fal.ai JS client\n\n![@fal-ai/client npm package](https://img.shields.io/npm/v/@fal-ai/client?color=%237527D7\u0026label=client\u0026style=flat-square)\n![@fal-ai/server-proxy npm package](https://img.shields.io/npm/v/@fal-ai/server-proxy?color=%237527D7\u0026label=proxy\u0026style=flat-square)\n![Build](https://img.shields.io/github/actions/workflow/status/fal-ai/fal-js/build.yml?style=flat-square)\n![License](https://img.shields.io/github/license/fal-ai/fal-js?style=flat-square)\n\n## About the Project\n\nThe fal JavaScript/TypeScript Client is a robust and user-friendly library designed for seamless integration of fal endpoints in Web, Node.js, and React Native applications. Developed in TypeScript, it provides developers with type safety right from the start.\n\n## Getting Started\n\nThe `@fal-ai/client` library serves as a client for fal apps hosted on fal. For guidance on consuming and creating apps, refer to the [quickstart guide](https://fal.ai/docs).\n\n### Client Library\n\nThis client library is crafted as a lightweight layer atop platform standards like `fetch`. This ensures a hassle-free integration into your existing codebase. Moreover, it addresses platform disparities, guaranteeing flawless operation across various JavaScript runtimes.\n\n\u003e **Note:**\n\u003e Ensure you've reviewed the [getting started guide](https://fal.ai/docs) to acquire your credentials, browser existing APIs, or create your custom functions.\n\n1. Install the client library\n   ```sh\n   npm install --save @fal-ai/client\n   ```\n2. Start by configuring your credentials:\n\n   ```ts\n   import { fal } from \"@fal-ai/client\";\n\n   fal.config({\n     // Can also be auto-configured using environment variables:\n     credentials: \"FAL_KEY\",\n   });\n   ```\n\n3. Retrieve your function id and execute it:\n   ```ts\n   const result = await fal.run(\"user/app-alias\");\n   ```\n\nThe result's type is contingent upon your Python function's output. Types in Python are mapped to their corresponding types in JavaScript.\n\nSee the available [model APIs](https://fal.ai/models) for more details.\n\n### The fal client proxy\n\nAlthough the fal client is designed to work in any JS environment, including directly in your browser, **it is not recommended** to store your credentials in your client source code. The common practice is to use your own server to serve as a proxy to fal APIs. Luckily fal supports that out-of-the-box with plug-and-play proxy functions for the most common engines/frameworks.\n\nFor example, if you are using Next.js, you can:\n\n1. Instal the proxy library\n   ```sh\n   npm install --save @fal-ai/server-proxy\n   ```\n2. Add the proxy as an API endpoint of your app, see an example here in [pages/api/fal/proxy.ts](https://github.com/fal-ai/fal-js/blob/main/apps/demo-nextjs-page-router/pages/api/fal/proxy.ts)\n   ```ts\n   export { handler as default } from \"@fal-ai/server-proxy/nextjs\";\n   ```\n3. Configure the client to use the proxy:\n   ```ts\n   import { fal } from \"@fal-ai/client\";\n   fal.config({\n     proxyUrl: \"/api/fal/proxy\",\n   });\n   ```\n4. Make sure your server has `FAL_KEY` as environment variable with a valid API Key. That's it! Now your client calls will route through your server proxy, so your credentials are protected.\n\nSee [libs/proxy](./libs/proxy/) for more details.\n\n### The example Next.js app\n\nYou can find a minimal Next.js + fal application examples in [apps/demo-nextjs-page-router/](https://github.com/fal-ai/fal-js/blob/main/apps/demo-nextjs-page-router).\n\n1. Run `npm install` on the repository root.\n2. Create a `.env.local` file and add your API Key as `FAL_KEY` environment variable (or export it any other way your prefer).\n3. Run `npx nx serve demo-nextjs-page-router` to start the Next.js app (`demo-nextjs-app-router` is also available if you're interested in the app router version).\n\nCheck our [Next.js integration docs](https://fal.ai/docs/integrations/nextjs) for more details.\n\n## Roadmap\n\nSee the [open feature requests](https://github.com/fal-ai/fal-js/labels/enhancement) for a list of proposed features and join the discussion.\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Make sure you read our [Code of Conduct](https://github.com/fal-ai/fal-js/blob/main/CODE_OF_CONDUCT.md)\n2. Fork the project and clone your fork\n3. Setup the local environment with `npm install`\n4. Create a feature branch (`git checkout -b feature/add-cool-thing`) or a bugfix branch (`git checkout -b fix/smash-that-bug`)\n5. Commit the changes (`git commit -m 'feat(client): added a cool thing'`) - use [conventional commits](https://conventionalcommits.org)\n6. Push to the branch (`git push --set-upstream origin feature/add-cool-thing`)\n7. Open a Pull Request\n\nCheck the [good first issue queue](https://github.com/fal-ai/fal-js/labels/good+first+issue), your contribution will be welcome!\n\n## License\n\nDistributed under the MIT License. See [LICENSE](https://github.com/fal-ai/fal-js/blob/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffal-ai%2Ffal-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffal-ai%2Ffal-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffal-ai%2Ffal-js/lists"}