{"id":16772529,"url":"https://github.com/pranav-kural/img-gen","last_synced_at":"2025-03-16T16:33:20.417Z","repository":{"id":250940699,"uuid":"835920305","full_name":"pranav-kural/img-gen","owner":"pranav-kural","description":"Image generation service using DALL·E 3 model","archived":false,"fork":false,"pushed_at":"2024-12-16T17:44:50.000Z","size":710,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T03:29:14.498Z","etag":null,"topics":["ai","generative-ai","image-generation","qvikchat","qvikchat-example"],"latest_commit_sha":null,"homepage":"","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/pranav-kural.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-07-30T19:40:02.000Z","updated_at":"2024-09-23T19:05:12.000Z","dependencies_parsed_at":"2025-01-23T03:37:29.552Z","dependency_job_id":null,"html_url":"https://github.com/pranav-kural/img-gen","commit_stats":null,"previous_names":["pranav-kural/img-gen"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-kural%2Fimg-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-kural%2Fimg-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-kural%2Fimg-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranav-kural%2Fimg-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranav-kural","download_url":"https://codeload.github.com/pranav-kural/img-gen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243896422,"owners_count":20365375,"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","generative-ai","image-generation","qvikchat","qvikchat-example"],"created_at":"2024-10-13T06:43:05.827Z","updated_at":"2025-03-16T16:33:20.325Z","avatar_url":"https://github.com/pranav-kural.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image Generation Service\n\nThis projects provides an API endpoint to generate images using the [DALL·E 3](https://openai.com/index/dall-e-3) model. The endpoint accepts the prompt text and returns an image generated based on the given prompt.\n\nThis project was built using the [QvikChat](https://qvikchat.pkural.ca) framework. QvikChat is an open-source framework that provides you with a solid foundation to build powerful AI-powered chat service endpoints quickly and efficiently\n\n**Pre-requisites:**\n\n- You will need an OpenAI API Key to use the DALL·E 3 model. You can get one by signing up on the [OpenAI website](https://openai.com/api/).\n- To run this project locally, you will need Node.js installed on your machine.\n\nYou can deploy this project to any Node.js platform if you want to. Although, if you do plan on deploying it, please ensure you have the necessary security controls in place, especially if the server endpoint is going to be exposed to the public. For setting up simple API-key based endpoint authentication, you can check the [Authentication](https://qvikchat.pkural.ca/authentication) page on QvikChat documentation.\n\n## Getting Started\n\nGet started by cloning the repository:\n\n```bash copy\ngit clone https://github.com/pranav-kural/img-gen.git\n```\n\n### Setup Environment Variables\n\nThis project uses the [DALL·E 3](https://openai.com/index/dall-e-3) model for image generation. To be able to use it, you will require an OpenAI API Key.\n\nCreate a `.env` file in the root of the project and add the following environment variables:\n\n```env copy\nOPENAI_API_KEY=\n```\n\nAlternatively, you can copy the `.env.tmp` file or rename it to `.env` and fill in the values.\n\n### Install Dependencies\n\nInstall the project dependencies using npm or pnpm:\n\n```bash\nnpm install\n```\n\nOr\n\n```bash\npnpm install\n```\n\n### Running the Project\n\nYou can run the following commands to get started:\n\n```bash\nnpm run dev # or pnpm dev\n```\n\nThe `dev` script is set in `package.json` to run `build` and then `start` the server. When using the default configurations, the server will start on `http://localhost:3400`.\n\nOnce, you run the project, you can test the endpoint defined in `src/index.ts` from terminal using command below:\n\n```bash copy\ncurl -X POST \"http://127.0.0.1:3400/img\" -H \"Content-Type: application/json\"  -d '{\"data\": { \"query\": \"a 3D painting like illustration of a cute lama in a hot balloon\" } }'\n```\n\nSample of an image generated by the above test prompt:\n\n![cute-lama-hot-balloon](https://github.com/user-attachments/assets/f35d4b47-aed9-496a-93e5-bef796a0cc9f)\n\nAbove example points to `http://127.0.0.1:3400`. You can change this port and host depending on where you are running the server and on which port.\n\nYou could also use the [Genkit Developer UI](#genkit-developer-ui) to test the endpoints.\n\n### Genkit Developer UI\n\nYou can run the Genkit developer UI to test the endpoints. Testing the endpoints using a graphical interface is probably the easiest way to get started. You can know more about the Genkit Developer UI [here](https://firebase.google.com/docs/genkit/devtools#genkit_developer_ui).\n\nStart the Genkit developer UI:\n\n```bash copy\nnpx genkit start\n```\n\nOR, you can install the Genkit CLI globally:\n\n```bash copy\nnpm i -g genkit\n```\n\nThen start the Genkit developer UI:\n\n```bash copy\ngenkit start\n```\n\nYou should be able to see the defined `img` endpoint under the **Flows** section in the left sidebar. Simply click on the endpoint and enter the query you want to test with. Clicking the **Run** button will send the query to the endpoint and the response generation process will start.\n\n## How it works?\n\nThe project uses the [DALL·E 3](https://openai.com/index/dall-e-3) model to generate images based on the given prompt.\n\nWe use [QvikChat](https://qvikchat.pkural.ca) to create the API endpoint that accepts the prompt text and returns the generated image.\n\nThe `src/index.ts` file contains the code that defines this endpoint. We first define the configurations for the image generation endpoint, and then provide these configurations to the `configureAndRunServer` method that will create the endpoint using the provided configurations and then start the server.\n\nThe code snippet below shows how the endpoint is configured:\n\n```typescript\nimport { configureAndRunServer } from \"@oconva/qvikchat\";\nimport { type DefineChatEndpointConfig } from \"@oconva/qvikchat/endpoints\";\n\n// Configurations for the image generation endpoint (using DALL·E 3 model)\nconst endpointConfig: DefineChatEndpointConfig = {\n  endpoint: \"img\",\n  modelConfig: {\n    name: \"dallE3\",\n    response_format: \"url\",\n  },\n  outputSchema: {\n    format: \"media\",\n    contentType: \"image/png\",\n  },\n};\n\n// Configure and run the server\nconfigureAndRunServer({\n  endpointConfigs: [endpointConfig],\n});\n```\n\n**Key points:**\n\n- `endpoint`: this is the server endpoint where the `HTTP POST` requests will be sent to.\n- `modelConfig`: this object contains the configuration for the model to be used. In this case, we are using the `dallE3` model and specifying that the response format should be a URL. This will ensure that model generates the image and returns the URL to the generated image. You can also use `b64_json` instead of `url` to get the base64 encoded image in the response.\n- `outputSchema`: this object specifies the format of the response that the endpoint is expected to produce. In this case, we are specifying that the response will be a media file with content type `image/png`.\n\nThanks to QvikChat, you can easily enable API-key based authentication with usage limits and response caching (with some limitations), by simply configuring your endpoint according to your needs. For more information, check the [QvikChat documentation](https://qvikchat.pkural.ca).\n\n## QvikChat\n\n**QvikChat** is an open-source framework that provides you with a solid foundation to build powerful AI-powered chat service endpoints quickly and efficiently. It includes support for **multiple types of conversations (open-ended, close-ended)**, **chat history**, **response caching**, **authentication**, **information retrieval using Retrieval Augmented Generation (RAG)**, and more.\n\n[Get Started](https://qvikchat.pkural.ca/getting-started) | [Documentation](https://qvikchat.pkural.ca)\n\n## QvikChat Starter Template\n\nThis project was scaffolded using the [QvikChat starter template](https://github.com/oconva/qvikchat-starter-template). It comes pre-configured with the following features:\n\n- **QvikChat**: QvikChat installed and configured to start serving chat endpoints.\n- **TypeScript**: TypeScript to allow you to write type-safe code efficiently.\n- **ESLint**: ESLint to enforce code quality and consistency.\n- **Prettier**: Prettier to format your code automatically and ensure consistent code style.\n- **GitHub Actions**: GitHub Actions to run your tests and lint your code automatically on every push.\n- **SWC**: For faster and more efficient TypeScript compilation.\n- **PNPM**: PNPM to manage your dependencies efficiently.\n\n## Issues\n\nIf you encounter any issues or bugs while using this project, please report them by following these steps:\n\n1. Check if the issue has already been reported by searching through [current issues](https://github.com/pranav-kural/img-gen/issues).\n2. If the issue hasn't been reported, create a new issue and provide a detailed description of the problem.\n3. Include steps to reproduce the issue and any relevant error messages or screenshots.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranav-kural%2Fimg-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranav-kural%2Fimg-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranav-kural%2Fimg-gen/lists"}