Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Ollama + FastAPI API, Building My Own AI API Using Ollama and FastAPI on a Linux VM

__Introduction Large Language Models (LLMs) like ChatGPT are usually accessed via cloud APIs. But what if we could run our own AI model locally and expose it as an API? In this project, I built a custom AI API using Ollama + FastAPI on a…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

__Introduction



Large Language Models (LLMs) like ChatGPT are usually accessed via cloud APIs.

But what if we could run our own AI model locally and expose it as an API?



In this project, I built a custom AI API using Ollama + FastAPI on a Linux virtual machine.

This API exposes LLM capabilities via REST endpoints, similar to how real-world AI microservices work.



This post covers the architecture, implementation, challenges, and learnings.



What is Ollama?



Ollama is a tool that allows us to run LLM models like Mistral, Llama, and Gemma locally.



It provides a local API endpoint:



http://localhost:11434



We can wrap this with FastAPI to build our own AI service.



Architecture





Step 1: Install Ollama on Linux VM

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



Verify installation:

ollama --version



Step 2: Pull an LLM Model

ollama pull mistral



Check available models:

ollama list



Step 3: Setup Python Environment

python3 -m venv ai-env

source ai-env/bin/activate

pip install fastapi uvicorn requests



Step 4: Build Ollama API using FastAPI

Create file ollama_api.py:




from fastapi import FastAPI
import requests

app = FastAPI()

OLLAMA_URL = "http://localhost:11434/api/generate"

@app.get("/")
def home():
return {"message": "Ollama AI API is running"}

@app.get("/health")
def health():
return {"status": "UP", "model": "mistral"}

@app.post("/chat")
def chat(prompt: str):
payload = {
"model": "mistral",
"prompt": prompt,
"stream": False
}
response = requests.post(OLLAMA_URL, json=payload)
return response.json()







Step 5: Run the API Server

uvicorn ollama_api:app --host 0.0.0.0 --port 9000



Step 6: Test the AI API

Test with curl

curl -X POST "http://localhost:9000/chat?prompt=Explain%20DevOps"



Test from Host Machine

curl -X POST "http://<VM-IP>:9000/chat?prompt=explain AI"





Challenges Faced

1 Networking Issues in VM




  • 0.0.0.0 cannot be used as a browser address.

  • Required using the VM IP address to access the API.



2 HTTPS vs HTTP




  • Browser attempted HTTPS while API was running on HTTP.

  • Solved by explicitly using HTTP.



3 Python PEP 668 Error




  • System Python was protected.

  • Solved using Python virtual environment (venv).



Key Learnings




  • Ollama can be used to run LLMs locally.

  • FastAPI is a great framework to expose AI models as microservices.

  • Virtual environments are essential in modern Linux systems.

  • Building APIs on VMs helps understand real DevOps workflows.

  • This architecture is similar to production AI services.

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - Ollama + FastAPI API, Building My Own AI API Using Ollama and FastAPI on a Linux VM
id: 81cf9123-8ed7-4354-a7f2-2b5be288df3c
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-26
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-26"
        description = "YARA Signature for "
    strings:
        $str = "Ollama + FastAPI API, Building" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Ollama  FastAPI API Building My Own AI A")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Ollama  FastAPI API Building My Own AI A*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Ollama  FastAPI API Building My Own AI A"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

CTI Threat Relationship Graph2 Knoten / 1 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Ollama + FastAPI API, Building My Own AI.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Ollama + FastAPI API, Building My Own AI API Using Ollama and FastAPI on a Linux VM

Thematisch verwandte Begriffe: Ollama, FastAPI, Building, Using · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-86066 | Horilla is an HR and CRM software. Prior to 2.0.0, approve_validate_atte…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag