Claude 3 Opus through an API to Custom GPT via Action

Hey all!

I was thinking that it would be a pretty neat hack to get Claude 3 Opus to my own GPT through an API so I don’t have to leave ChatGPT to use it. But I had really hard time to get the openapi specification to work. I have the API key stored in the “Authentication” thing they have in the Actions. This is what I have now in the openapi specification:

{
  "openapi": "3.1.0",
  "info": {
    "title": "Send and Receive Messages with Claude 3 Opus API",
    "version": "1.0.0",
    "description": "This API interaction sends a message to the Claude 3 Opus API and returns the response. It uses an API key for authentication, stored securely within the application."
  },
  "servers": [
    {
      "url": "api.anthropic.com/v1", 
      "description": "Anthropic API server"
    }
  ],
  "paths": {
    "/messages": {
      "post": {
        "summary": "Send message to Claude 3 Opus",
        "operationId": "sendMessageToClaude3Opus",
        "tags": [
          "Claude 3 Opus API"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "description": "Message content to send to Claude 3 Opus.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string",
                    "example": "claude-3-opus-20240229"
                  },
                  "max_tokens": {
                    "type": "integer",
                    "example": 1000
                  },
                  "temperature": {
                    "type": "number",
                    "example": 0
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "type": "string",
                          "example": "user"
                        },
                        "content": {
                          "type": "string",
                          "example": "How are you today?"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message successfully received and processed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The unique identifier for the message."
                    },
                    "content": {
                      "type": "string",
                      "description": "The response content from Claude 3 Opus."
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  }
}

How can I make it work?

2 Likes