/api/generate 쓸 때
/api/generate는 messages array 대신 prompt 문자열 하나 받아. 이런 모양이 맞을 때:
- Fill-in-the-middle (FIM) 코드 자동완성.
suffix필드에 cursor 뒤 코드 박으면 모델이 가운데 채워. - 대화 framing 없이 one-shot completion 원할 때.
- Raw mode (
raw: true) 보내서 모델 chat template 완전 우회 — 커스텀 prompt 형식 가진 fine-tuned 모델에 유용.
FIM이 킬러 use case
FIM은 endpoint의 성질이 아니라 모델 템플릿의 성질이야. suffix가 뭔가를 하는 건 그 모델의 Ollama 템플릿에 .Suffix 가지가 있을 때뿐이야. 그 가지가 prefix랑 suffix를 모델 고유의 fill-in-the-middle 토큰으로 감싸 주거든. 가지가 없으면 그냥 조용히 무시돼. 지금 그 가지를 갖고 있는 쪽은 qwen2.5-coder (base든 instruct든 전 태그), deepseek-coder-v2, starcoder2, 그리고 codellama:code 같은 Code Llama의 code 태그야. 믿기 전에 확인해. ollama show MODEL --template | grep -c Suffix, 아니면 그 모델 Capabilities 블록에 insert가 있는지 봐. 이런 모델에 prefix랑 suffix를 주면 함수 가운데를 채워 줘. Continue.dev의 local GitHub-Copilot 스타일 자동완성을 이게 굴려. Continue는 autocomplete 역할을 대놓고 FIM 기반이라고 적어 뒀고, provider로 Ollama를, 오픈 모델 추천으로 Qwen2.5-Coder 1.5B/7B를 걸어 뒀어. local 모델 쓰는 도구가 다 이 endpoint를 쓰는 건 아니야. Aider는 ollama_chat/으로 Ollama랑 얘기하고, Cursor의 Tab 모델은 자기네가 돌리는 서비스지 네 suffix 필드가 아니야.
다른 유용한 필드
images— base64 image string array (멀티모달 모델용).options—/api/chat이랑 동일.format—/api/chat이랑 동일.raw— boolean이야.true면 prompt에 template을 안 씌워.