Skip to content

POST

Send an HTTP POST request.

Signature

TypeScript
function post(
  url: string,
  data: any,
  config?: AxiosRequestConfig
): Promise<{
  headers: Record<string, string>;
  status: number;
  data: any;
}>;

Parameters

  • url: The request URL.
  • data: The request data.
  • config: The request config. Refer to the Axios docs for details.

Returns

  • The response object.

Examples

TypeScript
const res = await zeta.v1.http.post(
  `https://api.openai.com/v1/chat/completions`,
  {
    model: "gpt-3.5-turbo",

    messages: [{
      role: "user",
      content: "How can I take smarter notes?",
    }],
  },
  {
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${apiKey}`,
      "OpenAI-Organization": organization,
    },
  }
);