This repository demonstrates secure multimodal AI vision integration from C#. It is a small portfolio slice for teams that want to add document/image interpretation to an agentic workflow without hardcoding secrets, binding business logic to one provider, or making live model calls impossible to test.
The sample is designed to plug into an autonomous coding harness such as loop-design-build, a standard CI/CD pipeline, or a conventional .NET application boundary.
The business value is not the vision call by itself. The project shows the surrounding engineering discipline needed for corporate use: environment-based secrets, mockable AI boundaries, deterministic test paths, and a clean interface that lets orchestration code call vision capabilities without owning credentials or provider-specific request details.
It illustrates a useful enterprise pattern: let the model interpret visual input, but keep configuration, invocation policy, error handling, and downstream decisions in ordinary C# code.
- Secure by Default: Avoids hardcoding any API strings or secrets. Credentials are systematically extracted from environment variables (mapping cleanly to CI/CD Vaults/Secrets).
- Dependency Injection Ready: The
IVisionAgentinterface andHttpClientusage are structured to directly plug into standard .NET Core DI containers. - Agentic Harness Friendly: The code architecture is decoupled, allowing an orchestration agent to abstract the AI interactions and run unit tests deterministically.
The application uses the standard .NET configuration provider, which loads settings from multiple sources in the following priority (last one wins):
appsettings.json: Base settings for the endpoint and model.- User Secrets: Best for local development API keys.
- Environment Variables: Best for CI/CD and production.
| Key | Description | Default / Example |
|---|---|---|
AI_VISION_API_KEY |
Your AI provider API Key. | (Required for real inference) |
AI_VISION_ENDPOINT |
The REST API endpoint for the vision model. | https://api.example.com/v1/... |
AI_VISION_MODEL |
The specific model string to use. | vision-model-v1 |
AI_VISION_USE_MOCK |
Forces deterministic mock responses for demos/tests. | true / false |
The easiest way to set your API key locally without touching files is using User Secrets:
cd CSharpVisionAI
dotnet user-secrets init
dotnet user-secrets set "AI_VISION_API_KEY" "your-actual-api-key"# Start the web server
dotnet runNote
If AI_VISION_API_KEY is omitted, the demo will automatically inject a dummy key and use a mock response to ensure the UI remains testable without a real provider.
Once started, open your browser and navigate to http://localhost:5000. You can drag-and-drop an image and submit a prompt to see the secure vision analysis in action.
The solution includes a dedicated test harness to verify the API boundary and project logic:
cd CSharpVisionAI.Tests
dotnet runpublic interface IVisionAgent
{
Task<string> AnalyzeImageAsync(string imagePath, string prompt);
}The application leverages standard System.Net.Http along with System.Text.Json to communicate with standard AI Model REST APIs, ensuring zero heavy vendor-locked SDKs unless absolutely necessary for your business logic domain.
See docs/state/backlog.md for icebox notes on evolving the synchronous demo into a queued, observable AI job workflow with status tracking.
