{"id":22150376,"url":"https://github.com/follgad/zig-ai","last_synced_at":"2025-07-12T07:33:33.664Z","repository":{"id":265785286,"uuid":"896623421","full_name":"FOLLGAD/zig-ai","owner":"FOLLGAD","description":"OpenAI SDK with streaming support","archived":false,"fork":false,"pushed_at":"2025-02-16T18:17:11.000Z","size":17,"stargazers_count":37,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T13:51:21.979Z","etag":null,"topics":["openai","zig","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FOLLGAD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-11-30T21:23:56.000Z","updated_at":"2025-04-02T18:20:10.000Z","dependencies_parsed_at":"2025-07-12T07:33:25.441Z","dependency_job_id":null,"html_url":"https://github.com/FOLLGAD/zig-ai","commit_stats":null,"previous_names":["follgad/zig-ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FOLLGAD/zig-ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FOLLGAD%2Fzig-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FOLLGAD%2Fzig-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FOLLGAD%2Fzig-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FOLLGAD%2Fzig-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FOLLGAD","download_url":"https://codeload.github.com/FOLLGAD/zig-ai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FOLLGAD%2Fzig-ai/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264958193,"owners_count":23689010,"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":["openai","zig","zig-package"],"created_at":"2024-12-02T00:15:13.263Z","updated_at":"2025-07-12T07:33:33.655Z","avatar_url":"https://github.com/FOLLGAD.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-ai\n\nA simple OpenAI API client for Zig with streaming support.\n\nFind examples in the [`examples`](./examples) directory.\n\n## Usage\n\nWith streaming:\n\n```zig\nconst std = @import(\"std\");\nconst OpenAI = @import(\"zig-ai\");\n\npub fn main() !void {\n    // ...\n\n    var messages = std.ArrayList(OpenAI.Message).init(allocator);\n    try messages.append(.{\n        .role = \"system\",\n        .content = \"You are a helpful assistant\",\n    });\n    try messages.append(.{\n        .role = \"user\",\n        .content = \"User message here\",\n    });\n\n    const payload = OpenAI.ChatPayload{\n        .model = \"gpt-4o\",\n        .messages = messages.items,\n        .max_tokens = 1000,\n        .temperature = 0.2,\n    };\n\n    var stream = try openai.streamChat(payload, false);\n    defer stream.deinit();\n\n    while (try stream.next()) |response| {\n        // Stream the response to stdout\n        if (response.choices[0].delta.content) |content| {\n            try writer.writeAll(content);\n            try buf_writer.flush();\n        }\n    }\n}\n```\n\n## Installation\n\n```bash\n$ zig fetch --save git+https://github.com/FOLLGAD/zig-ai\n```\n\nand add `zig-ai` to your `build.zig` file:\n\n```zig\nconst std = @import(\"std\");\n\npub fn build(b: *std.Build) void {\n    const target = b.standardTargetOptions(.{});\n    const optimize = b.standardOptimizeOption(.{});\n\n    const exe = b.addExecutable(.{\n        .name = \"stream-cli\",\n        .root_source_file = b.path(\"examples/stream-cli.zig\"),\n        .target = target,\n        .optimize = optimize,\n    });\n\n    const module = b.dependency(\"zig-ai\", .{\n        .root_source_file = b.path(\"src/llm.zig\"),\n    });\n    exe.root_module.addImport(\"zig-ai\", module.module(\"zig-ai\"));\n}\n```\n\n## Usage\n\nSee the `examples` directory for usage examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffollgad%2Fzig-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffollgad%2Fzig-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffollgad%2Fzig-ai/lists"}