---
title: "Build a Content Analysis API in .NET Using Ollama for Automated SEO Metadata Generation"  
description: "(SEO) is a critical factor in improving website visibility, search rankings, and user engagement. As content volume increases, manually generating SEO"  
author: "Ravi Vishwakarma"  
published: 2026-06-11  
updated: 2026-06-11  
canonical: https://www.mindstick.com/blog/306965/build-a-content-analysis-api-in-dot-net-using-ollama-for-automated-seo-metadata-generation  
category: "artificial intelligence"  
tags: ["artificial intelligence", "ai", "ollama"]  
reading_time: 6 minutes  

---

# Build a Content Analysis API in .NET Using Ollama for Automated SEO Metadata Generation

Search Engine Optimization (SEO) is a critical factor in improving website visibility, search rankings, and user engagement. As content volume increases, manually generating SEO metadata such as tags, categories, keywords, and internal linking opportunities becomes inefficient.

By [integrating Ollama](https://www.mindstick.com/blog/306921/convert-ollama-api-in-public-api-for-content-writing) with a .NET Web API, developers can automate content analysis and generate [SEO](https://www.mindstick.com/services/search-engine-optimization) metadata using locally hosted [Large Language Models (LLMs)](https://www.mindstick.com/interview/34471/what-is-a-large-language-model-llm). This approach offers improved privacy, lower operational costs, and complete control over content processing.

In this article, we will build a Content Analysis API using ASP.NET Core and Ollama that automatically generates:

- SEO Tags
- Content Categories
- Focus Keywords
- Internal Link Keywords
- Meta Title Suggestions
- Meta Description Suggestions
- Content Summary

## Why Use Ollama with .NET?

Ollama allows developers to run powerful AI models locally without relying on external AI services.

Benefits include:

- Data privacy for unpublished content
- Reduced API costs
- Faster local processing
- Easy integration with .NET applications
- Support for Llama, Gemma, Mistral, [DeepSeek](https://www.mindstick.com/blog/305270/the-chinese-ai-app-deepseek-was-downloaded-by-millions-why), and other models

This makes Ollama an ideal solution for content management systems, blogging platforms, and SEO automation tools.

## Solution Architecture

The overall workflow is straightforward:

```plaintext
Article Content
      |
      V
ASP.NET Core API
      |
      V
    Ollama
      |
      V
SEO Metadata JSON
      |
      +--> Category
      +--> Tags
      +--> Keywords
      +--> Link Keywords
      +--> Meta Title
      +--> Meta Description
      +--> Summary
```

## Prerequisites

Before starting, install Ollama:

```plaintext
curl -fsSL https://ollama.com/install.sh | sh
```

Pull a model:

```plaintext
ollama pull llama3
```

Run the model:

```plaintext
ollama run llama3
```

By default, Ollama exposes an API at:

```plaintext
http://localhost:11434
```

## Create ASP.NET Core Web API

Create a new project:

```plaintext
dotnet new webapi -n ContentAnalysisApi
cd ContentAnalysisApi
```

## Create SEO Metadata Models

Create a folder named **Models**.

### SeoMetadataResponse.cs

```cs
// Namespace declaration
namespace ContentAnalysisApi.Models
{
    // SEO response model
    public class SeoMetadataResponse
    {
        // Primary category
        public string Category { get; set; }

        // SEO tags
        public List<string> Tags { get; set; }

        // Focus keywords
        public List<string> Keywords { get; set; }

        // Internal linking keywords
        public List<string> LinkKeywords { get; set; }

        // Meta title
        public string MetaTitle { get; set; }

        // Meta description
        public string MetaDescription { get; set; }

        // Content summary
        public string Summary { get; set; }
    }
}
```

### ContentRequest.cs

```cs
namespace ContentAnalysisApi.Models
{
    // Incoming content request
    public class ContentRequest
    {
        // Article content
        public string Content { get; set; }
    }
}
```

## Create Ollama Request Models

### OllamaRequest.cs

```cs
namespace ContentAnalysisApi.Models
{
    // Request sent to Ollama
    public class OllamaRequest
    {
        // AI model name
        public string Model { get; set; }

        // Prompt text
        public string Prompt { get; set; }

        // Disable streaming response
        public bool Stream { get; set; }
    }
}
```

### OllamaResponse.cs

```cs
namespace ContentAnalysisApi.Models
{
    // Response returned by Ollama
    public class OllamaResponse
    {
        // Generated content
        public string Response { get; set; }
    }
}
```

## Create Content Analysis Service

Create a folder named **Services**.

### ContentAnalysisService.cs

```cs
using System.Text;
using System.Text.Json;
using ContentAnalysisApi.Models;

namespace ContentAnalysisApi.Services
{
    // Service responsible for communication with Ollama
    public class ContentAnalysisService
    {
        // HttpClient instance
        private readonly HttpClient _httpClient;

        // Constructor injection
        public ContentAnalysisService(HttpClient httpClient)
        {
            _httpClient = httpClient;
        }

        // Analyze content
        public async Task<string> AnalyzeContentAsync(string content)
        {
            // SEO prompt
            var prompt = $@"
Analyze the article and return ONLY valid JSON.

{{
    ""category"": """",
    ""tags"": [],
    ""keywords"": [],
    ""linkKeywords"": [],
    ""metaTitle"": """",
    ""metaDescription"": """",
    ""summary"": """"
}}

Rules:
- Generate SEO category.
- Generate tags.
- Generate keywords.
- Generate internal link keywords.
- Generate SEO meta title.
- Generate SEO meta description.
- Generate summary.

Article:
{content}
";

            // Create request payload
            var request = new OllamaRequest
            {
                Model = "llama3",
                Prompt = prompt,
                Stream = false
            };

            // Serialize request
            var json = JsonSerializer.Serialize(request);

            // Create HTTP content
            var httpContent = new StringContent(
                json,
                Encoding.UTF8,
                "application/json");

            // Send request to Ollama
            var response = await _httpClient.PostAsync(
                "http://localhost:11434/api/generate",
                httpContent);

            // Ensure success status
            response.EnsureSuccessStatusCode();

            // Read response body
            var responseBody =
                await response.Content.ReadAsStringAsync();

            // Parse Ollama response
            var ollamaResponse =
                JsonSerializer.Deserialize<OllamaResponse>(
                    responseBody);

            // Return generated JSON string
            return ollamaResponse?.Response;
        }
    }
}
```

## Register Service

Update **Program.cs**.

```cs
using ContentAnalysisApi.Services;

// Create builder
var builder = WebApplication.CreateBuilder(args);

// Register controllers
builder.Services.AddControllers();

// Register HttpClient
builder.Services.AddHttpClient();

// Register service
builder.Services.AddScoped<ContentAnalysisService>();

// Swagger
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Enable swagger
app.UseSwagger();
app.UseSwaggerUI();

app.MapControllers();

app.Run();
```

## Create API Controller

### ContentAnalysisController.cs

```cs
using Microsoft.AspNetCore.Mvc;
using ContentAnalysisApi.Models;
using ContentAnalysisApi.Services;

namespace ContentAnalysisApi.Controllers
{
    [ApiController]
    [Route("api/content")]
    public class ContentAnalysisController : ControllerBase
    {
        private readonly ContentAnalysisService _service;

        // Constructor
        public ContentAnalysisController(
            ContentAnalysisService service)
        {
            _service = service;
        }

        // POST api/content/analyze
        [HttpPost("analyze")]
        public async Task<IActionResult> Analyze(
            [FromBody] ContentRequest request)
        {
            // Validate content
            if (string.IsNullOrWhiteSpace(request.Content))
            {
                return BadRequest("Content is required.");
            }

            // Analyze content
            var result =
                await _service.AnalyzeContentAsync(
                    request.Content);

            // Return response
            return Ok(result);
        }
    }
}
```

## Example API Request

```plaintext
POST /api/content/analyze

Content-Type: application/json

{
  "content": "Artificial Intelligence is transforming SEO and digital marketing..."
}
```

## Example Response

```plaintext
{
  "category": "Artificial Intelligence",
  "tags": [
    "AI",
    "SEO",
    "Content Marketing",
    "Digital Marketing"
  ],
  "keywords": [
    "AI SEO",
    "SEO automation",
    "content analysis"
  ],
  "linkKeywords": [
    "technical SEO",
    "keyword research",
    "AI tools"
  ],
  "metaTitle": "How AI is Transforming SEO in 2025",
  "metaDescription": "Discover how AI-powered tools are revolutionizing SEO and content optimization.",
  "summary": "An overview of AI-driven SEO automation and content optimization techniques."
}
```

## Automatic Internal Link Injection

The `linkKeywords` field can be used to automatically connect related articles within your [CMS](https://www.mindstick.com/services/cms-software-development).

Example:

| Link Keyword | Related Article |
| --- | --- |
| Technical SEO | Technical SEO Best Practices |
| Keyword Research | Advanced Keyword Research Guide |
| AI Tools | Best AI Tools for Content Marketing |

For technology websites, these keywords can be matched against existing content from [MindStick Technology Articles](https://mindstick.com/), relevant discussions on [MindStick Answers](https://answers.mindstick.com/), or opinion-based content from [YourViews by MindStick](https://yourviews.mindstick.com/) to strengthen internal linking and improve crawlability.

## Production Improvements

For enterprise-grade implementations:

### Structured JSON Output

Use Ollama's JSON mode:

```plaintext
{
  "format": "json"
}
```

### Background Processing

Implement:

- [BackgroundService](https://www.mindstick.com/forum/162019/how-to-implement-background-jobs-in-asp-dot-net)
- [Hangfire](https://www.mindstick.com/forum/162019/how-to-implement-background-jobs-in-asp-dot-net)
- Azure Queue Storage
- [RabbitMQ](https://www.mindstick.com/interview/33987/what-is-rabbitmq)

### Caching

Store generated metadata in:

- [Redis](https://answers.mindstick.com/blog/332/building-a-production-grade-chat-application-with-asp-dot-net-core-signalr-redis-and-react)
- [SQL Server](https://training.mindstick.com/courses/103/sql-server-upcoming5)
- [PostgreSQL](https://answers.mindstick.com/qa/92847/what-is-postgresql)

### Additional SEO Features

Generate:

- FAQ Schema
- Open Graph Tags
- Twitter Cards
- Canonical URLs
- Article Schema Markup
- Related Content Recommendations

## Conclusion

Combining ASP.NET Core and Ollama enables developers to create a powerful AI-driven content analysis platform capable of generating categories, tags, keywords, summaries, meta titles, meta descriptions, and internal linking opportunities automatically. This reduces manual SEO effort, improves content discoverability, and creates a scalable workflow for modern content management systems while maintaining complete control over data and AI infrastructure.

---

Original Source: https://www.mindstick.com/blog/306965/build-a-content-analysis-api-in-dot-net-using-ollama-for-automated-seo-metadata-generation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
