Skip to content

ewhauser/codex-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codex Go SDK

Experimental Go SDK for the local Codex app-server JSON-RPC protocol.

This package starts codex app-server --listen stdio://, initializes the app-server session, and exposes Go APIs for login, models, threads, turns, streaming notifications, approval handling, and retryable app-server errors.

Install

go get github.com/ewhauser/codex-sdk-go

You also need a local codex binary available on PATH, or an explicit binary path through AppServerConfig.

Example

package main

import (
	"context"
	"fmt"
	"log"

	codex "github.com/ewhauser/codex-sdk-go"
)

func main() {
	ctx := context.Background()

	client, err := codex.NewCodex(ctx)
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	thread, err := client.ThreadStart(ctx)
	if err != nil {
		log.Fatal(err)
	}

	result, err := thread.Run(ctx, "Say hello in one sentence.")
	if err != nil {
		log.Fatal(err)
	}
	if result.FinalResponse != nil {
		fmt.Println(*result.FinalResponse)
	}
}

Generated Protocol Types

The generated/ package is produced from:

codex app-server generate-json-schema

Refresh it with:

go generate ./generated

Run tests with:

go test ./...

Examples

Runnable examples live in examples/:

go run ./examples/01_quickstart_constructor

About

Port of https://github.com/openai/codex/tree/main/sdk/python to Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages