Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arindam200/nebius-hono
An example of using Nebius AI with Hono.
https://github.com/arindam200/nebius-hono
ai cloudflare cloudlfare-pages hono
Last synced: 7 days ago
JSON representation
An example of using Nebius AI with Hono.
- Host: GitHub
- URL: https://github.com/arindam200/nebius-hono
- Owner: Arindam200
- Created: 2025-02-07T19:56:24.000Z (7 days ago)
- Default Branch: main
- Last Pushed: 2025-02-07T21:00:41.000Z (7 days ago)
- Last Synced: 2025-02-07T22:18:22.519Z (7 days ago)
- Topics: ai, cloudflare, cloudlfare-pages, hono
- Language: TypeScript
- Homepage: https://hono-with-nebius-ai.pages.dev
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nebius AI with Hono Example
This is a project to provide an example of using [Nebius AI](https://dub.sh/nebius) with Hono.
## Features
- **Minimal & Lightweight:** Built with Hono and React for a streamlined, easy-to-follow example.
- **Multi-Model Support:** Easily switch between Nebius AI models like Deepseek R1, Meta-Llama, and others.
- **Real-Time Streaming:** Displays streaming responses from the AI in real time.
- **Input Validation:** Utilizes Zod for validating incoming data.
- **Dual Rendering:** Supports both server-side and client-side rendering.## Requirements
- **Node.js** v18+
- **Nebius Account** (For Inference Models)
- **Cloudflare Account** (for deploying to Cloudflare Pages/Workers)## Installation
1. **Clone the Repository:**
```sh
git clone https://github.com/Arindam200/nebius-hono.git
cd nebius-hono
```2. **Install Dependencies:**
```sh
npm install
```3. **Set Up Environment Variables:**
This project uses environment variables to configure your Nebius API key. You can set the variable using one of the following methods:
- **.env File:** Create a `.env` file in the root directory (or copy from `.env.example`) with the following content:
```env
VITE_NEBIUS_API_KEY="Your NEBIUS API KEY"
```- **.dev.vars File:** When developing for Cloudflare Workers or if you prefer to keep your secrets separate, you can alternatively define your environment variables inside a `.dev.vars` file. This file is automatically detected by the Hono environment adapter. For example:
```env
NEBIUS_API_KEY="Your NEBIUS API KEY"
```## Development
Start the development environment using Vite:
```sh
npm run dev
```Then open your browser at [http://localhost:5173/](http://localhost:5173/) to interact with the chat application.
## Deployment
To build and deploy the project to Cloudflare Pages, follow these steps:
1. **Build the Application:**
The following command builds both the client and server bundles:
```sh
npm run build
```2. **Deploy to Cloudflare Pages:**
Use the Wrangler CLI (configured via `wrangler.toml`) to deploy:
```sh
npm run deploy
```> **π‘ Note:**
>
> In a production environment, ensure that the `VITE_NEBIUS_API_KEY` (or `NEBIUS_API_KEY` if using a `.dev.vars` file) environment variable is set in your hosting platform's environment settings.## Project Structure
```
.
βββ .env # Local environment variables file
βββ .env.example # Example environment variables file
βββ .dev.vars # Development environment variables for Cloudflare Workers
βββ package.json # Project manifest and scripts
βββ README.md # Project documentation
βββ wrangler.toml # Cloudflare Pages/Workers configuration
βββ vite.config.ts # Vite configuration file
βββ src
βββ client.tsx # React-based client entry point
βββ index.tsx # Hono server/API entry point
βββ renderer.tsx # React renderer for Hono pages
βββ styles.css # Application and component-specific styles
```## Configuration
### Environment Variables
- **VITE_NEBIUS_API_KEY / NEBIUS_API_KEY:**
This key is essential for your application to interact with the Nebius AI API. Use the `VITE_NEBIUS_API_KEY` variable in the `.env` file for local development with Vite or use `NEBIUS_API_KEY` in `.dev.vars` if youβre working with Cloudflare Workers.### Switching AI Models
By default, the project uses a Nebius AI model defined in `src/index.tsx`. To switch between models (e.g., from Meta-Llama to Deepseek R1), update the `model` parameter in the AI API call:
```typescript
const result = await client.chat.completions.create({
temperature: 0.6,
model: "meta-llama/Meta-Llama-3.1-70B-Instruct", // Or change to "deepseek/R1"
messages: messages,
});
```This allows you to quickly swap models based on your current requirements.
## Contributing
Contributions are welcome! If you have suggestions, improvements, or bug fixes, please open an issue or submit a pull request. Ensure that any contributions adhere to the project's style and testing guidelines.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for the full license text.
## Support
If you encounter issues or have any questions, please open an issue in the GitHub repository or contact the maintainers directly.