Skip to content

jashwanth84/Infinity-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NVIDIA API client (Python + C++ via pybind11)

Layout

  • base64_module.cpp — C++ extension: fast file → base64 encoder
  • setup.py — builds the C++ extension into a Python-importable module
  • main.py — Python script that calls the NVIDIA chat completions API, using the C++ extension for any file/image encoding

Build the C++ extension

pip install pybind11
python setup.py build_ext --inplace

This produces a fastb64*.so file in this directory that main.py imports directly.

Set your API key

Do not put the key in the source code. Export it as an environment variable instead:

export NVIDIA_API_KEY="nvapi-..."

(If you pasted a key into this chat earlier, treat it as compromised — revoke/regenerate it in your NVIDIA NGC account.)

Run

python main.py

To send an image with the prompt:

call_api("What's in this image?", image_path="photo.png")

The C++ extension handles reading + base64-encoding the file; Python handles the HTTP request and JSON response.

Deploy to Render as a Background Worker

Files added for this: Dockerfile, .dockerignore, requirements.txt, worker.py, render.yaml.

worker.py calls the API on a loop (interval set by POLL_INTERVAL_SECONDS, default 3600s) and shuts down cleanly on SIGTERM, which Render sends when stopping or redeploying a worker.

Option A — Blueprint (render.yaml), one click:

  1. Push this folder to a GitHub/GitLab repo.
  2. In Render: New > Blueprint → pick the repo. Render reads render.yaml and creates the worker for you.
  3. Go to the new service's Environment tab and set NVIDIA_API_KEY (it's marked sync: false so it isn't committed to your repo).
  4. Deploy.

Option B — Manual:

  1. Push this folder to a repo.
  2. In Render: New > Background Worker → pick the repo.
  3. Runtime: Docker (Render will find the Dockerfile automatically).
  4. Add environment variable NVIDIA_API_KEY (and optionally POLL_INTERVAL_SECONDS) under the Environment tab.
  5. Create the worker.

Render will build the Docker image (compiling the C++ extension during the build step) and start worker.py. Check the Logs tab to confirm it's polling successfully. Note that main.py checks for NVIDIA_API_KEY at startup, so if it's missing the worker will exit immediately with a clear error in the logs (and Render will keep restarting it) rather than running with a broken key — set the env var and redeploy to fix.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages