11 Ollama JSON API curl
Ollama serve komutu ile arkaplan hizmeti başlatıyoruz
ollama serve
http://localhost:11434/
Ollama API örnek ve dokumantasyonu
İlk örnekler için curl komutunu kullanacağız. Windows’ta aşağıdaki scoop komutu ile kurabilirsiniz.
scoop install curl
API sunum noktası varsayılan değerlerde: http://localhost:11434/api uç noktasıdır.
API JSON nesneleri ile çağırılır. Çağrılabilecek
{
"model": "ds15",
"prompt": "What is your name?"
}
En basit çağrıda sonuçlar bir akış (stream) olarak döndürülür.
curl http://localhost:11434/api/generate -d '{"model": "ds15", "prompt": "What is your name?" } '
Daha kolay olması için stream false ile çağıralım.
curl http://localhost:11434/api/generate -d '{"model": "ds15", "prompt": "What is your name?", "stream": false } '
curl http://localhost:11434/api/chat -d '{"model": "ds15", "prompt": "What is your name?", "stream": false } '
context length değiştirme
curl http://localhost:11434/api/generate -d '{
"model": "ds15",
"prompt": "Why is the sky blue?",
"options": {
"num_ctx": 4096
}
}'