Get and Test an OpenAI Key

Sign in to the OpenAI API Platform, open the API key settings for the project you want to use, and create a key there. Test it with a small text request before giving it to an agent.

Create the key in the intended project

Decide which project should own the agent's API usage before generating the credential. Sign in to the OpenAI API Platform, select that project, and open its API key settings. If you cannot create a key, check your project access with its owner. In the same project, review the billing settings and follow any activation steps shown for your account before planning a live test.

Store the new key in the secret store or environment used by the process that will make the call. OpenAI's Responses API example passes the value from OPENAI_API_KEY as a bearer credential. Keep the value out of prompts, source control, and shared diagnostic output.

Use a project alias and an outcome such as secret loaded in the log. Neither the credential nor a request authorization header belongs in an acceptance worksheet.

Code Interpreter | OpenAI API

Budget the pilot from both token counts

OpenAI's pricing table lists Standard gpt-6.2-sol at $2 per million uncached input tokens and $10 per million output tokens. In an illustrative pilot, suppose you run 100 text-only requests with 2,000 uncached input tokens and 500 output tokens each. Input costs 0.2 × $2, or $0.40. Output costs 0.05 × $10, or $0.50. The estimated token charge is $0.90 under those assumptions.

Before increasing traffic, verify the exact model and service tier in OpenAI's API pricing table. Check the project's usage after the pilot and account for any tools you add. If you need the pilot to stop after 100 requests, enforce that count in the caller and include retries in the count.

Test from the environment where the application runs, then record the usage attribution independently. A successful request alone does not identify the intended billing owner.

Pricing | OpenAI API

Test the credential in the application environment

From the environment that will run the agent, make a single text request to the Responses API using a model available to the project. Use a harmless prompt with an obvious expected answer, such as asking for the sum of 14 and 29. Leave tools and automatic retries off for this test. Record the request outcome and returned text while omitting request headers from the log.

A successful response containing 43 establishes that the test process could call that model with its configured credential. If the API reports an authentication error, check whether the running process received the intended secret. If the response identifies a model access or billing problem, resolve that issue before generating another key.

Code Interpreter | OpenAI API

Check which credential OpenClaw actually uses

OpenClaw supports both OpenAI API key authentication and ChatGPT or Codex subscription authentication under the openai provider ID. If you need usage billed through the API project, configure an API key auth profile and inspect the account or authentication route selected for the test session. A working chat and an openai model label establish that the session responded, while the selected route determines which credential it used.

If the direct API request succeeds but OpenClaw fails, inspect the credential available to the running gateway and repeat the test in a fresh session. If the session answers through subscription authentication, select the API key route and verify the resulting request against the API project's usage records once they update.

OpenAI - OpenClaw

Sources