Skip to content

imrany/wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

71 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Wrapper

A lightweight gRPC + RESTful wrapper for AI models. Built in Go, this service exposes a unified interface for AI generation via both protocol-level gRPC and HTTP/JSON endpoints. Includes Swagger UI, Docker support, and flexible configuration via flags or environment variables.

πŸš€ Features

  • βœ… gRPC service: AiService.GenAi(prompt)
  • βœ… RESTful HTTP endpoint: POST /v1/genai
  • βœ… Swagger UI for interactive API testing
  • βœ… Docker-ready with multi-port support
  • βœ… Configurable via flags, .env, or inline environment variables
  • βœ… Graceful shutdown and signal handling
  • βœ… Gemini API key integration

πŸ§ͺ Quick Start

1. Run Locally

go run main.go --port=8000 --api-key=your_key_here --model=gemini-2.5-pro

Or use environment variables:

export PORT=8000
export API_KEY=your_key_here
export MODEL=gemini-2.5-pro
go run main.go

2. Build Docker Image

docker build -t wrapper .

Or pull from GitHub Container Registry:

docker pull ghcr.io/imrany/wrapper

3. Run with Docker

Option A: Inline flags

docker run -d --name wrapper \
  -p 8000:8000 \  # gRPC
  -p 8090:8090 \  # REST + Swagger
  ghcr.io/imrany/wrapper \
  --port=8000 \
  --api-key=your_key_here
  --model=gemini-2.5-pro

Option B: .env file

Create .env:

PORT=8000
API_KEY="your_key_here"
MODEL="gemini-2.5-pro" # or "gpt-5.1-2025-11-13"

Run:

docker run --env-file .env -p 8000:8000 -p 8090:8090 ghcr.io/imrany/wrapper

πŸ“‘ API Endpoints

1. REST (HTTP/JSON)

POST /v1/genai
Content-Type: application/json
Body: "Hello AI"

Example

curl -X POST http://localhost:8090/v1/genai \
  -H "Content-Type: application/json" \
  -d '"Hello AI"'

2. gRPC

service AiService {
  rpc GenAi(GenAiRequest) returns (GenAiResponse);
}

Example

grpcurl -insecure localhost:8000 \
  wekalist.api.v1.AiService.GenAi \
  -d '{"prompt": "Hello AI"}'

3. Swagger UI

Visit: http://localhost:8090/swagger/

🧠 Response Format

{
  "prompt": "Hello AI",
  "response": "Hello! How can I help you today?\n",
  "status": null
}

πŸ” Environment Variables

Variable Description
PORT gRPC server port
API_KEY Gemini API key
MODEL Provides model name, e.g gemini-2.5-pro, gpt-5.1-2025-11-13

πŸ›‘οΈ Health Check

GET /healthz

Returns 200 OK with body ok.

🧠 License & Credits

Built by Imran Licensed under MIT

About

A multi-model AI wrapper, supports gRPC and HTTP connections

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors 2

  •  
  •