Skip to main content

integration

Ollama provides multiple integration options including REST API, command-line interface, and language-specific SDKs. The integration framework supports both synchronous and streaming responses for ## real-time applications.

API Integration

The REST API runs on port 11434 by default and provides endpoints for model management and inference. Basic API usage includes generating completions, managing models, and streaming responses.

1.Test the API connection:


Bash
curl http://localhost:11434/api/version

2.Generate a completion:


Bash

curl http://localhost:11434/api/generate -d '{
"model": "llama2",
"prompt": "Why is the sky blue?"
}'

3.Model Management Download and manage models through the CLI:

Bash
ollama pull llama2
ollama pull codellama
ollama list

4.Remove unused models:

Bash

ollama rm model_name

5.Programming Language Integration Popular language bindings include Python, JavaScript, Go, and Rust. Install the Python client:


Bash

pip install ollama

Example Python integration:

Python
import ollama
response = ollama.chat(model='llama2', messages=[
{'role': 'user', 'content': 'Why is the sky blue?'}
])
## Docker Integration
Run Ollama in Docker for containerized deployments:

Bash

docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama