Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
Add support for OPENAI_ORG_ID environment variable for setting the OpenAI organization ID when using an API key with multiple OpenAI organizations.
Dane Schneiderb4d77745984b
diff --git a/README.md b/README.mdindex 556aa4d2..155d8ef4 100644--- a/README.md+++ b/README.md@@ -123,6 +123,7 @@ Then [generate an API key here.](https://platform.openai.com/account/api-keys)cd your-projectexport OPENAI_API_KEY=...export OPENAI_ENDPOINT=... # optional e.g. https://<your-proxy>/v1+export OPENAI_ORG_ID=... # optional - set the OrgID if you have multiple OpenAI orgsplandex new```diff --git a/app/cli/plan_exec/build.go b/app/cli/plan_exec/build.goindex b23c3118..36f0b018 100644--- a/app/cli/plan_exec/build.go+++ b/app/cli/plan_exec/build.go@@ -41,6 +41,7 @@ func Build(params ExecParams, buildBg bool) (bool, error) {ProjectPaths: paths.ActivePaths,ApiKey: os.Getenv("OPENAI_API_KEY"),Endpoint: os.Getenv("OPENAI_ENDPOINT"),+ OpenAIOrgId: os.Getenv("OPENAI_ORG_ID"),}, stream.OnStreamPlan)term.StopSpinner()diff --git a/app/cli/plan_exec/tell.go b/app/cli/plan_exec/tell.goindex ef043d7b..25b43b69 100644--- a/app/cli/plan_exec/tell.go+++ b/app/cli/plan_exec/tell.go@@ -72,6 +72,7 @@ func TellPlan(IsUserContinue: isUserContinue,ApiKey: os.Getenv("OPENAI_API_KEY"),Endpoint: os.Getenv("OPENAI_ENDPOINT"),+ OpenAIOrgId: os.Getenv("OPENAI_ORG_ID"),}, stream.OnStreamPlan)term.StopSpinner()diff --git a/app/server/handlers/plans_exec.go b/app/server/handlers/plans_exec.goindex d301cee5..73d21e43 100644--- a/app/server/handlers/plans_exec.go+++ b/app/server/handlers/plans_exec.go@@ -87,7 +87,7 @@ func TellPlanHandler(w http.ResponseWriter, r *http.Request) {}}- client := model.NewClient(requestBody.Endpoint, requestBody.ApiKey)+ client := model.NewClient(requestBody.ApiKey, requestBody.Endpoint, requestBody.OpenAIOrgId)err = modelPlan.Tell(client, plan, branch, auth, &requestBody)if err != nil {@@ -144,7 +144,7 @@ func BuildPlanHandler(w http.ResponseWriter, r *http.Request) {return}- client := model.NewClient(requestBody.Endpoint, requestBody.ApiKey)+ client := model.NewClient(requestBody.ApiKey, requestBody.Endpoint, requestBody.OpenAIOrgId)numBuilds, err := modelPlan.Build(client, plan, branch, auth)if err != nil {diff --git a/app/server/model/client.go b/app/server/model/client.goindex 41169cc1..f73918f5 100644--- a/app/server/model/client.go+++ b/app/server/model/client.go@@ -11,11 +11,15 @@ import (const OPENAI_STREAM_CHUNK_TIMEOUT = time.Duration(30) * time.Second-func NewClient(endpoint, apiKey string) *openai.Client {+func NewClient(apiKey, endpoint, orgId string) *openai.Client {config := openai.DefaultConfig(apiKey)if endpoint != "" {config.BaseURL = endpoint}+ if orgId != "" {+ config.OrgID = orgId+ }+return openai.NewClientWithConfig(config)}diff --git a/app/shared/req_res.go b/app/shared/req_res.goindex 3c4f18d4..a6e4c389 100644--- a/app/shared/req_res.go+++ b/app/shared/req_res.go@@ -114,6 +114,7 @@ type TellPlanRequest struct {IsUserContinue bool `json:"isUserContinue"`ApiKey string `json:"apiKey"`Endpoint string `json:"endpoint"`+ OpenAIOrgId string `json:"openAIOrgId"`ProjectPaths map[string]bool `json:"projectPaths"`}@@ -121,6 +122,7 @@ type BuildPlanRequest struct {ConnectStream bool `json:"connectStream"`ApiKey string `json:"apiKey"`Endpoint string `json:"endpoint"`+ OpenAIOrgId string `json:"openAIOrgId"`ProjectPaths map[string]bool `json:"projectPaths"`}diff --git a/guides/USAGE.md b/guides/USAGE.mdindex f3a4494d..19a7d839 100644--- a/guides/USAGE.md+++ b/guides/USAGE.md@@ -1,11 +1,20 @@# Using Plandex 🛠️+## OpenAI API key 🔑++If you don't have an OpenAI account, first [sign up here.](https://platform.openai.com/signup)++Then [generate an API key here.](https://platform.openai.com/account/api-keys)++Support for more model providers is coming soon.+## New plan 🪄```bashcd your-projectexport OPENAI_API_KEY=...export OPENAI_ENDPOINT=... # optional e.g. https://<your-proxy>/v1+export OPENAI_ORG_ID=... # optional - set the OrgID if you have multiple OpenAI orgsplandex new```diff --git a/releases/cli/versions/0.8.2.md b/releases/cli/versions/0.8.2.mdindex c9ad971b..124309bf 100644--- a/releases/cli/versions/0.8.2.md+++ b/releases/cli/versions/0.8.2.md@@ -1,3 +1,4 @@- Fix root level --help/-h to use custom help command rather than cobra's help message (re: https://github.com/plandex-ai/plandex/issues/25)- Include 'survey' fork (https://github.com/plandex-ai/survey) as a proper module instead of a local reference (https://github.com/plandex-ai/plandex/pull/37)-- Add support for OPENAI_ENDPOINT environment variable for custom OpenAI endpoints (https://github.com/plandex-ai/plandex/pull/46)\ No newline at end of file+- Add support for OPENAI_ENDPOINT environment variable for custom OpenAI endpoints (https://github.com/plandex-ai/plandex/pull/46)+- Add support for OPENAI_ORG_ID environment variable for setting the OpenAI organization ID when using an API key with multiple OpenAI organizations.\ No newline at end of filediff --git a/releases/server/versions/0.8.3.md b/releases/server/versions/0.8.3.mdindex 368d3faa..e27eeaa7 100644--- a/releases/server/versions/0.8.3.md+++ b/releases/server/versions/0.8.3.md@@ -1,2 +1,4 @@- SMTP_FROM environment variable for setting from address when self-hosting and using SMTP (https://github.com/plandex-ai/plandex/pull/39)-- Add support for OPENAI_ENDPOINT environment variable for custom OpenAI endpoints (https://github.com/plandex-ai/plandex/pull/46)\ No newline at end of file+- Add support for OPENAI_ENDPOINT environment variable for custom OpenAI endpoints (https://github.com/plandex-ai/plandex/pull/46)+- Add support for OPENAI_ORG_ID environment variable for setting the OpenAI organization ID when using an API key with multiple OpenAI organizations.+- Fix for unhelpful "Error getting plan, context, convo, or summaries" error message when OpenAI returns an error for invalid API key or insufficient credits (https://github.com/plandex-ai/plandex/issues/32)\ No newline at end of file