First of all I had no Idea where to put this but I put it into DirectX because it was somewhat related to the topic.

As to the actual question... I was wondering how exactly are modern game engines such as Crytech, Unity, etc.... able to fully develop their game then just port it to Windows, Mac, Xbox 360, PS3, and so on. To be somewhat more specific how are they able to use DirectX, OpenGl, and then use it for the console that's opposite of what it's for.

Do they use both languages and then just write an api layer over them so that it makes a call to use whichever language is needed for the port?

That is in a nutshell my question and I hope you were able to understand what I was asking.

You more or less already answered the question - the engines just use an abstraction layer to make the actual rendering calls behind an engine specific API. This lets the actual core code and game code use whichever rendering system is selected at the time, without even knowing which rendering API is being used.

I'm sure each engine uses different techniques to implement this strategy, but that is the basic idea.

Ahh I see, that was something I was wondering about and not quite too sure, but it seems like it would be inefficient because it has a lot of overhead sitting around to make calls to the different APIs.

But I suppose its a necessary sacrifice to extend portability to different platforms

There doesn't have to be any overhead at runtime. You already need to compile different versions of your executable for each platform you target, so when you compile them you can just have the engine use the appropriate rendering code path for that platform and ignore everything else.