{"id":24560129,"url":"https://github.com/dravenk/ollama-zig","last_synced_at":"2025-10-23T02:41:55.796Z","repository":{"id":271496195,"uuid":"913275583","full_name":"dravenk/ollama-zig","owner":"dravenk","description":"Ollama Zig library","archived":false,"fork":false,"pushed_at":"2025-02-03T07:23:17.000Z","size":75,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T18:07:32.078Z","etag":null,"topics":["deepseek","llama","llm","llms","ollama","ollama-api","ollama-client","zig","zig-library","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dravenk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-07T11:18:13.000Z","updated_at":"2025-03-12T18:05:27.000Z","dependencies_parsed_at":"2025-01-08T05:46:47.760Z","dependency_job_id":"3d20f4bc-f8fe-40db-a701-88ff72eebba6","html_url":"https://github.com/dravenk/ollama-zig","commit_stats":null,"previous_names":["zon-dev/ollama-zig","dravenk/ollama-zig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dravenk%2Follama-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dravenk%2Follama-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dravenk%2Follama-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dravenk%2Follama-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dravenk","download_url":"https://codeload.github.com/dravenk/ollama-zig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933379,"owners_count":20370988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek","llama","llm","llms","ollama","ollama-api","ollama-client","zig","zig-library","zig-package"],"created_at":"2025-01-23T07:15:20.260Z","updated_at":"2025-10-23T02:41:55.778Z","avatar_url":"https://github.com/dravenk.png","language":"Zig","funding_links":[],"categories":["Libraries","Data \u0026 Science"],"sub_categories":["Large Language Model"],"readme":"# Ollama Zig Library\n\nThe Ollama Zig library provides the easiest way to integrate Zig 0.14+ projects with [Ollama](https://github.com/ollama/ollama).\n\n## Prerequisites\n\n- [Ollama](https://ollama.com/download) should be installed and running\n- Pull a model to use with the library: `ollama pull \u003cmodel\u003e` e.g. `ollama pull llama3.2`\n  - See [Ollama.com](https://ollama.com/search) for more information on the models available.\n\n## Install\n\n```sh\nzig fetch --save git+https://github.com/dravenk/ollama-zig.git\n```\n\n## Usage\n\nAdding to build.zig\n```zig\n    const ollama = b.dependency(\"ollama-zig\", .{\n        .target = target,\n        .optimize = optimize,\n    });\n    exe.root_module.addImport(\"ollama\", ollama.module(\"ollama\"));\n```\n\nImport it in your code:\n```zig \nconst ollama = @import(\"ollama\");\n```\n\nSee [types.zig](src/types.zig) for more information on the response types.\n\n## Streaming responses\n\nResponse streaming can be enabled by setting `.stream = true`.\n\n```zig\ntry ollama.chat(.{ .model = \"llama3.2\", .stream = true, .messages = \u0026.{\n    .{ .role = .user, .content = \"Why is the sky blue?\" },\n} });\n```\n\n## API\n\nThe Ollama Zig library's API is designed around the [Ollama REST API](https://github.com/ollama/ollama/blob/main/docs/api.md)\n\n### Chat\n\n```zig\n    var responses = try ollama.chat(.{ .model = \"llama3.2\", .stream = false, .messages = \u0026.{\n        .{ .role = .user, .content = \"Why is the sky blue?\" },\n    } });\n    while (try responses.next()) |chat| {\n        const content = chat.message.content;\n        std.debug.print(\"{s}\", .{content});\n    }\n```\n\n### Generate\n\n```zig\n    var responses = try ollama.generate(.{ .model = \"llama3.2\", .prompt = \"Why is the sky blue?\" });\n    while (try responses.next()) |response| {\n        const content = response.response;\n        std.debug.print(\"{s}\", .{content});\n    }\n\n```\n\n### Show\n\n```zig\ntry ollama.show(\"llama3.2\");\n```\n\n### Create\n\n```zig\ntry ollama.create(.{ .model = \"mario\", .from = \"llama3.2\", .system = \"You are Mario from Super Mario Bros.\" });\n```\n\n### Copy\n\n```zig\ntry ollama.copy(\"llama3.2\", \"user/llama3.2\");\n```\n\n### Delete\n(In plan)Wait for the upstream update. see https://github.com/ollama/ollama/issues/8753\n```zig\ntry ollama.delete(\"llama3.2\")\n```\n\n### Pull\n\n```zig\ntry ollama.pull(\"llama3.2\")\n```\n\n### Push\n\n```zig\ntry ollama.push(.{ .model = \"dravenk/llama3.2\"});\n```\n\n### Embed or Embed (batch)\n\n```zig\n    var input = std.ArrayList([]const u8).init(allocator);\n    try input.append(\"The sky is blue because of rayleigh scattering\");\n    try input.append(\"Grass is green because of chlorophyll\");\n\n    var responses = try ollama.embed(.{\n        .model = \"dravenk/llama3.2\",\n        .input = try input.toOwnedSlice(),\n    });\n    while (try responses.next()) |response| {\n        std.debug.print(\"total_duration: {d}\\n\", .{response.total_duration.?});\n        std.debug.print(\"prompt_eval_count: {d}\\n\", .{response.prompt_eval_count.?});\n    }\n```\n\n### Ps\n\n```zig\ntry ollama.ps()\n```\n### Version\n\n```zig\ntry ollama.version()\n```\n\n## Errors\n\nErrors are raised if requests return an error status or if an error is detected while streaming.\n\n```zig\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdravenk%2Follama-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdravenk%2Follama-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdravenk%2Follama-zig/lists"}